简体   繁体   中英

Yii: can't use LIMIT in a mysql query

I'm using Yii, and I want to select 5 rows from mysql starting from the third row.

For Example, I have these rows:

ID - NAME
1  - abc
2  - bcd
3  - hdf
4  - fgr
5  - gdf
...

and I want to select 5 rows, starting from the third row.

My code:

$rows = Users::model()->findAll(array(
    'order' => 'id DESC',
    'limit' => '3, 5'
));

The problem this selects nothing.

There is an offset parameter.

$rows = Users::model()->findAll(array(
  'order' => 'id DESC',
  'limit' => '5',
  'offset' => '3'
));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM