SQL Query

I have 3 tables --- Product (prodId, Name) Country (countryId, Name) ProductValue (prodId, countryId, value)

I wish to query ProductValue.value according to prodId for every countries.

SQL Query -> "SELECT * , ( SELECT value FROM Productvalue pv WHERE pv.prodId = p.prodId AND countryId = c.countrycode ) AS value FROM Product p JOIN Countries c WHERE p.prodId =1"

How can I query in phalcon controller using execute()? Please help me that. Thanks

edited Jul '14

this way:

$heads = $this->db->query(
            FROM heads h
            INNER JOIN sites_has_heads shh ON shh.head_id=h.id
            WHERE shh.site_id=?
            ORDER BY h.realname',

But why do not you use models?