Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii findAllByAttributes LIMIT

Tags:

yii

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?

like image 444
Faceles Avatar asked Nov 04 '13 08:11

Faceles


1 Answers

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
));
like image 168
Chetan Ameta Avatar answered Nov 09 '22 05:11

Chetan Ameta