Cakephp select from subquery

I'm using a subquery to calculate certain fields

place_id, count(*) as count, IFNULL(AVG(reviews.rating),0) as value

now I want to be able to select these values but don't seem to find out how, only in a WHERE clause...

Upvotes: 0

Views: 1069

Answers (1)

alexdd55
alexdd55

Reputation: 1117

take the ids you will get from this query as an array and put it in a find().

$this->Model->find('all', array('conditions' => array('Model.id' => $list_of_ids);

if you put an array of Ids in a query, cake automatically builds an query with the correct subquery.

Upvotes: 1

Related Questions