Yii Framework Forum: Fetch All Rows Without Last One - Yii Framework Forum

Jump to content

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

Fetch All Rows Without Last One Rate Topic: ***** 1 Votes

#1 User is offline   samilo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 231
  • Joined: 04-October 12

Posted 24 April 2013 - 02:33 AM

Hi all

I need to fetch all rows from one table , for example fetch all news without last news .

Controller :

 	$dataProvider=new CActiveDataProvider('News', array(
	'criteria'=>array(
    	'condition'=>'active=1',
    	  
	),
	'pagination'=>array(
    	'pageSize'=>10,
    	
	),
));


How to do that ?

Thanks in advance
0

#2 User is offline   Fabrizio Caldarelli 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 311
  • Joined: 21-March 13
  • Location:Rome, Italy

Posted 24 April 2013 - 02:36 AM

Remove pageSize in pagination or set this value with very large value as 9999999999
0

#3 User is offline   samilo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 231
  • Joined: 04-October 12

Posted 24 April 2013 - 03:32 AM

My friend Fabrizio , you didn't understood my question in clear way , my target fetch all records without last item .

For example :

this is news table
news_id title
1 ssssssss
2 saadsadadsads
3 ssssssssssss
4 sadsadsadsadss
5 wqweqewqwqeqw
6 wwwwwwwwqew


I need to fetch al rows with out item number 6 (last item) - (news_id=6)

Thanks in advance







0

#4 User is offline   Fabrizio Caldarelli 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 311
  • Joined: 21-March 13
  • Location:Rome, Italy

Posted 24 April 2013 - 03:37 AM

You could try with this condition:

WHERE ... AND id < (SELECT MAX(id) from table)

So

        $dataProvider=new CActiveDataProvider('News', array(
        'criteria'=>array(
        'condition'=>'active=1 AND id < (SELECT MAX(id) FROM news)',
        ),
        'pagination'=>array(
        'pageSize'=>10,
        
        ),
));

1

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