Yii Framework Forum: When Pagination Is Enabled With() Condition Is Not Considered - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

When Pagination Is Enabled With() Condition Is Not Considered Rate Topic: -----

#1 User is offline   yiibie 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 06-July 12

Posted 23 October 2012 - 10:18 AM

Yii 1.1.12
Windows, XAMPP

If I set pagination to any value except from false, it won't consider the with part in my criteria.

$criteria = new CDbCriteria(array(
                    'with' => array('files' => array('select' => 'title,filename', 'condition' => 'files.id = 79')),
                ));
        $dataProvider = new CActiveDataProvider(new GeneralCommercial(), array(
                    'criteria' => $criteria,
                ));
        $dataProvider->setPagination(false);
        var_dump(count($dataProvider->getData(true))); // 0 correct value


$criteria = new CDbCriteria(array(
                    'with' => array('files' => array('select' => 'title,filename', 'condition' => 'files.id = 79')),
                ));
        $dataProvider = new CActiveDataProvider(new GeneralCommercial(), array(
                    'criteria' => $criteria,
                ));


        $dataProvider->setPagination(array('pageSize' => 4));
        var_dump(count($dataProvider->getData(true))); // 2 (number of all objects in the table


And still more confusing:
$criteria = new CDbCriteria(array(
                    'with' => array('files' => array('select' => 'title,filename', 'condition' => 'files.id = 79')),
                ));
        $dataProvider = new CActiveDataProvider(new GeneralCommercial(), array(
                    'criteria' => $criteria,
                ));
        $dataProvider->setPagination(false);

        $dataProvider->setPagination(array('pageSize' => 4));
        var_dump(count($dataProvider->getData(true))); // 0, correct


So I think there is anything wrong. Just downloaded today 1.1.12, but the problem appeared in 1.1.10, too.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users