// where语句 AND条件
public function demo3()
{
$result = Db::table('user')
->field(['name','password'])
->where([
'name'=>['=','root'],
'userid'=>['>',4]
])
->select();
dump($result);
}
// where语句 AND条件(闭包)--引入变量进行查询
public function demo4()
{
$myname = 'admin';
$result = Db::table('user')
->field(['name','password'])
->where(function($query) use ($myname){
$query->where('userid','=',1)
->where('name','=',$myname);
})
->select();
dump($result);
}
// where语句 AND条件(闭包缩写)
public function demo5()
{
dump(
Db::select(
function ($query){
$query->table('user')
->field(['name','password'])
->where([
'userid'=>['>',1],
'password'=>['=','123456']
]);
}
));
}