1、where 的用法,参考一下:https://www.kancloud.cn/manual/thinkphp5/135182
2、where条件 or,and 同时使用 。一定要打括号。不然执行会出错。
('a'=1 and 'b'=2) or ('c'=3 and 'd'=4) and 'e'=5
$where_1['a'] = 1; $where_1['b'] = 2; $where_2['c'] = 3; $where_2['d'] = 4; $where_main['_complex'] = array( $where_1, $where_2, '_logic' => 'or' ); $where_main['e'] = 5; $this->user->where($where_main)->select();
SELECT * FROM `ecs_order_info` WHERE ( ( `order_status` = 5 AND `shipping_status` = 2 ) OR `order_status` = 6 ) AND `user_id` = 1
怎么检测我们写的sql语句没有错呢?执行下面这条语句就可以了,只会翻译成sql语句,不会执行。 echo $order->where($final)->fetchSql(true)->select();