php 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/02 9:23 UTC
Read the original article Hit count: 152

Filed under:
|
|
|

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. SELECTCategory.SQL_CALC_FOUND_ROWS,

Is there anyway of doing this? Any help would be greatly appreciated, thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql