首页 > Web开发 > 详细

thinkphp5.1 Array to string conversion问题 where express error:问题

时间:2021-05-31 21:36:17      阅读:94      评论:0      收藏:0      [点我收藏+]
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));
}

thinkphp5.1 Array to string conversion问题 where express error:问题

原文:https://www.cnblogs.com/jackduan/p/14832535.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!