thinkphp5.1的sql中in的优化写法
$order = Db::table("client_order_info")
->where("order_id in (" . $batch['order_id_is_return_str'] . ")")
->order("merchantkeynum","asc")
->select();
//优化有的写法,把字符串转成了数组,字符串为空就会成为空数组,也不会报错
$map["order_id"] = ['in',explode(",",$batch['order_id_is_return_str'])];
$order = Db::table("client_order_info")
->where($map)
->order("merchantkeynum","asc")
->select();
版权声明:若无特殊注明,本文皆为《菜鸟站长》原创,转载请保留文章出处。
本文链接:thinkphp5.1的sql中in的优化写法 - https://wziyi.net/?post=320