特殊条件查询
find_in_set
生成条件 find_in_set(1, name)
? 代表参数绑定,可以直接写明条件,第二个参数不传递即可,但需要注意防范注入风险
$data = Model::create()->where("find_in_set(?, name)", [1])->get();
复杂where or
// 生成大概语句:where status = 1 AND (id > 10 or id < 2)
Model::create()->where('status', 1)->where(' (id > 10 or id <2) ')->get();
lock table
Model::create()->func(function ($builder){
// ...
$builder->lockTable("tableName");
// ...
});
释放表锁
Model::create()->func(function ($builder){
// ...
$builder->unlockTable();
// ...
});
select for update
Model::create()->get(function ($builder){
// ...
$builder->selectForUpdate();
// ...
});
当前内容版权归 EasySwoole 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 EasySwoole .