limit in CActiveDataProvider

I faced some problem ,

when I use CActiveDataProvider I can’t set limit in its criteria,

I try bellows code, but it is not working…

$dataProvider=new CActiveDataProvider(‘MstTender’,

array(


        'criteria' => array( 


	'condition'=>'isActive=1', 		           


            'order' => 'lastDateSubmission DESC',


        'limit' => 5,


        ),


      )		


);

please any idea?????

you must set the offset




$dataProvider=new CActiveDataProvider('MstTender',

array(

'criteria' => array(

'condition'=>'isActive=1',

'order' => 'lastDateSubmission DESC',

'offset'=>0,

'limit' => 5,

),

)

);



Maybe the pagination override the limit.

Try with:





$dataProvider=new CActiveDataProvider('MstTender',

   array(

      'criteria' => array( 

          'condition'=>'isActive=1', 

          'order' => 'lastDateSubmission DESC',

      ),

      'pagination'=>array(

          'pageSize'=>'5'

      )

  

   )	

);



thnx everybody,

I found my solutions

bellows code is work nicely…

$dataProvider=new CActiveDataProvider(‘MstTender’,

		array(


        'criteria' => array( 


			'condition'=>'isActive=1', 		           


            'order' => 'lastDateSubmission DESC',


        ),


		 'pagination' => array('pageSize' => 2,),


         'totalItemCount' => 2,


      )		


	);

total item count is not needed…

@zaccaria,

I have tried not using totalitemCount but its not helping to limit records. I am not sure what is the issue.

Regards,

Krupa Sagar.

CArraydataprovider available

For example,




 $criteria = array(

                'condition'=>'t.isActive = :active',

                'params' => array('active' => 1 ),

                'order' => 't.lastDateSubmission desc',

                'offset' => 0,

                'limit' => 30

            );

 $list = MstTender::model()->findAll($criteria);

                

                $_list = new CArrayDataProvider($list, array(

                            'id' => 'listid',

                            'keyField' => 'isid', /*table primary field name*/

                            'pagination'=>array(

                                'pageSize'=>5

                            ),

                        ));



You are right.

We need to set ‘pagination’ to false, like this:




$dataProvider = new CActiveDataProvider(

	Book::model(),

	array(

		'criteria' => array(

			'limit' => 20,

			'order' => 'created DESC'

		),

		'pagination' => false

	)

);



Thank you, very much

Thanx! Had the same problem - found your solution!

if pagination=>false limit works. is there another right way limit and pagination works together?