Select yii2 中最后一条记录之前的一个
Select one before the last record in yii2
我想通过在 yii2 中使用 activerecord 查询来访问 我的 table 数据库中的最后一条记录。
例如像这样:
$query = Product::find()
->where(['NOT IN', 'price_off', ''])
->orderBy('id DESC')
->limit('1,1') //But this limit not work correctlly
->one();
This page 没有帮助我。
mysql 的 LIMIT
语法是 LIMIT (offset, row_count)
。有一个 OFFSET
选项不是 mysql 特定的。 Yii 的查询生成器有一个 offset function 你应该改用:
$query = Product::find()
->where(['NOT IN', 'price_off', ''])
->orderBy('id DESC')
->limit(1)
->offset(1)
->one();
我想通过在 yii2 中使用 activerecord 查询来访问 我的 table 数据库中的最后一条记录。
例如像这样:
$query = Product::find()
->where(['NOT IN', 'price_off', ''])
->orderBy('id DESC')
->limit('1,1') //But this limit not work correctlly
->one();
This page 没有帮助我。
mysql 的 LIMIT
语法是 LIMIT (offset, row_count)
。有一个 OFFSET
选项不是 mysql 特定的。 Yii 的查询生成器有一个 offset function 你应该改用:
$query = Product::find()
->where(['NOT IN', 'price_off', ''])
->orderBy('id DESC')
->limit(1)
->offset(1)
->one();