cakephp and SQL_CALC_FOUND_ROWS
Posted
by Lizard
on Stack Overflow
See other posts from Stack Overflow
or by Lizard
Published on 2010-06-02T09:21:36Z
Indexed on
2010/06/03
3:14 UTC
Read the original article
Hit count: 412
I am trying to add the SQL_CALC_FOUND_ROWS into a query (Please note this isn't for pagination)
please note I am trying to add this to a cakePHP query the code I currently have is below:
return $this->find('all', array(
'conditions' => $conditions,
'fields'=>array('SQL_CALC_FOUND_ROWS','Category.*','COUNT(`Entity`.`id`) as `entity_count`'),
'joins' => array('LEFT JOIN `entities` AS Entity ON `Entity`.`category_id` = `Category`.`id`'),
'group' => '`Category`.`id`',
'order' => $sort,
'limit'=>$params['limit'],
'offset'=>$params['start'],
'contain' => array('Domain' => array('fields' => array('title')))
));
Note the 'fields'=>array('SQL_CALC_FOUND_ROWS','
this obviously doesn't work as It tries to apply the SQL_CALC_FOUND_ROWS
to the table e.g. SELECT
Category.
SQL_CALC_FOUND_ROWS,
Is there anyway of doing this? Any help would be greatly appreciated, thanks.
© Stack Overflow or respective owner