Faceles
Faceles

Reputation: 453

Yii findAllByAttributes LIMIT

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?

Upvotes: 7

Views: 24915

Answers (1)

Chetan Ameta
Chetan Ameta

Reputation: 7896

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
));

Upvotes: 19

Related Questions