yiisoft/yii — Issue #376: limit and offset
Author: igorska
Created: 2012-02-20 18:59:13+00:00
State: open

Wrong request when use limit and offset in relation AR
example
$posts = array(
'translates' => array(
'select' => 'header, language_id,active',
'joinType' => "INNER JOIN",
'condition' => "language_id = ".Yii::app()->user->getState('languageId'),
'order'	=> 'active, translates.id desc',
));

$findCriteria = new CDbCriteria();
$findCriteria->offset = 0;
$findCriteria->limit = 20;
$posts = Posts::model()->with($posts)->findAll($findCriteria);

Query in log
Querying SQL: SELECT `t`.`id` AS `t0_c0`, `translates`.`header` AS `t1_c3`,
`translates`.`language_id` AS `t1_c2`, `translates`.`active` AS `t1_c5`,
`translates`.`id` AS `t1_c0` FROM `posts` `t` LEFT JOIN `posts_data`
`translates` ON (`translates`.`post_id`=`t`.`id`) WHERE (`t`.`id` IN (2,
3, 4)) ORDER BY active, translates.id desc

Wrong IN in query