1. 限定数量
一般用于查询
<?php
// 限定结果和数量
public function limit1()
{
$data = Db::table('wh_record')
->where([
['IDX', '>', 150000],
['UNIT', '=', 2],
['STATUS', 'IN', ['归还', '借出']],
])
->field('IDX AS ID, BUILD AS 阶段, ISN AS 序列号, STATUS AS 状态')
->limit(10)
->select();
return json($data);
}
极少数情况下用于修改
<?php
Db::table('think_user')
->where('score',100)
->limit(3)
->update(['level'=>'A']);
2. 用于分页
<?php
// 用于分页
public function limit2()
{
$data = Db::table('wh_record')
->where([
['IDX', '>', 150000],
['UNIT', '=', 2],
['STATUS', 'IN', ['归还', '借出']],
])
->field('IDX AS ID, BUILD AS 阶段, ISN AS 序列号, STATUS AS 状态')
->limit(0, 10)
->select();
return json($data);
}