Yii Framework Forum: Pagination - Yii Framework Forum

Jump to content

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

Pagination Rate Topic: -----

#1 User is offline   ilikeme 

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

Posted 11 January 2013 - 07:49 AM

I'm trying to pagination...
I don't like YII way then I'm tryign to make one by myself

This is what I've done, but it's not showing any item...
when I delete the limit then it's show all the items
$page = ($page < 1 || intval($page) != $page) ? 1 : $page;
$per_page = 12;
$start_form = ($page-1)*$per_page;
$items = Item::model()->findAllByAttributes(array('p_catgory'=>$p),array('order'=>'id DESC','limit'=>"$start_form,$per_page"));

0

#2 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,112
  • Joined: 16-February 11
  • Location:Japan

Posted 11 January 2013 - 08:02 AM

$items = Item::model()->findAllByAttributes(
    array(
        'p_catgory'=>$p
    ),
    array(
        'order'=>'id DESC',
        'offset'=>$start_form,
        'limit'=>$per_page,
    )
);


But I like Yii way. :)
0

#3 User is offline   ilikeme 

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

Posted 11 January 2013 - 08:13 AM

View Postsoftark, on 11 January 2013 - 08:02 AM, said:

$items = Item::model()->findAllByAttributes(
    array(
        'p_catgory'=>$p
    ),
    array(
        'order'=>'id DESC',
        'offset'=>$start_form,
        'limit'=>$per_page,
    )
);


But I like Yii way. :)


Thanks very much ;)
0

#4 User is offline   ilikeme 

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

Posted 11 January 2013 - 08:30 AM

View Postsoftark, on 11 January 2013 - 08:02 AM, said:

$items = Item::model()->findAllByAttributes(
    array(
        'p_catgory'=>$p
    ),
    array(
        'order'=>'id DESC',
        'offset'=>$start_form,
        'limit'=>$per_page,
    )
);


But I like Yii way. :)


Ummm and how do I get all the items (MODLE=ITEM) which their `p_catgory` is 4 OR 6 OR 9 for example...
Thanks for help ;)
0

#5 User is offline   rootbear 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 225
  • Joined: 17-June 11

Posted 11 January 2013 - 01:25 PM

View Postilikeme, on 11 January 2013 - 08:30 AM, said:

Ummm and how do I get all the items (MODLE=ITEM) which their `p_catgory` is 4 OR 6 OR 9 for example...
Thanks for help ;)


try:

$items = Item::model()->findAllByAttributes(
    array(),
    array(
        'condition'=>'p_catgory = :p1 or p_catgory = :p2 or p_catgory = :p3',
				'params'=> array( 
					':p1' => '4',
					':p2' => '6',
					':p1' => '9',
				),
        'order'=>'id DESC',
        'offset'=>$start_form,
        'limit'=>$per_page,
    )
);


also: catgory# in sequence 6,4,9 would work better, ;)
I enjoy the Yii.sy coding life here.
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