7

Hello I have the code

$allLogins = IpAddressLogin::model()->findAllByAttributes(
    array(
        'user_id' => Yii::app()->user->id,
        'type' => 'user'
    ),
    array(
        'order' => 'date desc',
        'limit' => '15, 10',
    ));

I want to get 10 records from number 15 record. But It just gives me only the last 15 records.
It parses only the first number(15) in 'limit'. How can I set LIMIT 15, 10 in findAllByAttributes?

Faceles
  • 453
  • 1
  • 5
  • 16
  • 6
    You need `limit` and `offset`, check here: http://stackoverflow.com/a/12943125/133408 –  Nov 04 '13 at 08:49

1 Answers1

19

You should use offset for it. Please have a look on below code it will help you to set required limit

$allLogins = IpAddressLogin::model()->findAllByAttributes(
array(
    'user_id' => Yii::app()->user->id,
    'type' => 'user'
),
array(
    'order' => 'date desc',
    'limit' => 10,
    'offset' => 15
));
Chetan Ameta
  • 7,696
  • 3
  • 29
  • 44