Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
// empty 没有值,返回1,有值返回0
$user = Db::table('oyk_user')->where('uid',16)->select();
if($user->isEmpty()) {
}
// =, <> !=,> >=
$user = Db::table('oyk_user')->where('uid','>','6')->select();
// like模糊查询,%代表有多个不确定位置的值,_代表只有一个不确定的值
// 前面加not,就是取反
$user = Db::table('oyk_user')->where('nickname','like','小编%')->select();
// between区间查询
$user = Db::table('oyk_user')->where('uid','between','5,13')->select();
// 指定查询 in
$user = Db::table('oyk_user')->where('uid','in','1,3,5')->select();
// table和name都是表明,name不带前缀
$user = Db::table('oyk_user')->select();
$user = Db::name('oyk_user')->select();
// 排序用order,原生中是order by asc 正序,desc是倒叙
$user = Db::table('oyk_user')->order('id desc')->select();
// 翻页,获取条数,limit,1个参数代表获取多少条。2个参数代表从第几条到第几条
$user = Db::table('shop')->limit(0,5)->select()->toArray();
// 翻页进阶版,用page,第一个参数是当前页数,第二个参数是一次获取多少条
$user = Db::table('shop')->page(2,5)->select()->toArray();
// 聚合查询
$user = Db::table('shop')
->field('id','title','img')
->where('id','>','6')
->order('id ASC')
->select()
->toArray();