thinkphp5.1构建查询数组,$where可以是二位数组或三维数组,
Db::table('think_user')
    ->where([
        ['name', 'like', $name . '%'],
        ['title', 'like', '%' . $title],
        ['id', '>', $id],
        ['status', '=', $status],
    ])
    ->select();

$map = [
        ['name', 'like', 'thinkphp%'],
        ['title', 'like', '%thinkphp'],
        ['id', '>', 0],
    ];
Db::table('think_user')
    ->where([ $map ])
    ->where('status',1)
    ->select();
发现构建查询数组时,如果要指定数字下标,第一个下标必须是0,源码  thinkphp\library\think\db\Builder.php 305行
if (key($value) !== 0) {
throw new Exception('where express error:' . var_export($value, true));
}

相关文章:

  • 2021-04-28
  • 2021-11-14
  • 2021-06-03
  • 2021-05-17
  • 2022-12-23
  • 2022-03-08
  • 2021-09-04
  • 2021-09-09
猜你喜欢
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
相关资源
相似解决方案