Yii Framework Forum: CActiveDataProvider's 'limit' criteria not working - Yii Framework Forum

Jump to content

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

CActiveDataProvider's 'limit' criteria not working Rate Topic: -----

#1 User is offline   Gaurav C. 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 08-August 11

Posted 18 August 2011 - 03:18 PM

Well, I've tried a lot but cannot get this piece of code working as expected.
Following is inside an action method,

$dataProvider=new CActiveDataProvider('Tips', array(
	'criteria'=>array('order'=>'create_time DESC','limit'=>1)
));


The order of the output is descending but 'limit'? It just does not work. I'm expecting to get a single result after putting 'limit'->1 and yet it gives me data from all the rows.

The view file corresponding to this contains,

<?php $this->widget('zii.widgets.CListView', array(
	'dataProvider'=>$dataProvider,
	'summaryText'=>'',
	'itemView'=>'_tips',
)); ?>


Really not able to understand what is going wrong here. Kindly help.
0

#2 User is offline   PeRoChAk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 575
  • Joined: 26-November 10
  • Location:Lahore, Pakistan

Posted 18 August 2011 - 05:20 PM

It will work only when you set the pagination to false in CActiveDataProvider
Cheers
Perochak
Web Design - Logo Design - Application Development

My Blog | Forums Comparison
4

#3 User is offline   chriscao 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 03-February 10

Posted 16 January 2012 - 02:13 AM

Good~
0

#4 User is offline   rajesh chaurasia 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 12-January 13
  • Location:Mohali

Posted 16 May 2013 - 02:21 AM

View PostGaurav C., on 18 August 2011 - 03:18 PM, said:

Well, I've tried a lot but cannot get this piece of code working as expected.
Following is inside an action method,

$dataProvider=new CActiveDataProvider('Tips', array(
	'criteria'=>array('order'=>'create_time DESC','limit'=>1)
));


The order of the output is descending but 'limit'? It just does not work. I'm expecting to get a single result after putting 'limit'->1 and yet it gives me data from all the rows.

The view file corresponding to this contains,

<?php $this->widget('zii.widgets.CListView', array(
	'dataProvider'=>$dataProvider,
	'summaryText'=>'',
	'itemView'=>'_tips',
)); ?>


Really not able to understand what is going wrong here. Kindly help.



hi friends you can set limit by
$dataProvider=new CActiveDataProvider('model', array(
'criteria'=>array(
'order'=>'create_time DESC',

),
'pagination' => array('pageSize' => 8,),
'totalItemCount' => 8,

));
its working nice.
0

#5 User is offline   sefburhan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 136
  • Joined: 08-February 12
  • Location:islamabad

Posted 20 May 2013 - 07:22 AM

View PostGaurav C., on 18 August 2011 - 03:18 PM, said:

Well, I've tried a lot but cannot get this piece of code working as expected.
Following is inside an action method,

$dataProvider=new CActiveDataProvider('Tips', array(
	'criteria'=>array('order'=>'create_time DESC','limit'=>1)
));


The order of the output is descending but 'limit'? It just does not work. I'm expecting to get a single result after putting 'limit'->1 and yet it gives me data from all the rows.

The view file corresponding to this contains,

<?php $this->widget('zii.widgets.CListView', array(
	'dataProvider'=>$dataProvider,
	'summaryText'=>'',
	'itemView'=>'_tips',
)); ?>


Really not able to understand what is going wrong here. Kindly help.

http://www.yiiframew...ia#limit-detail
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