ThinkPHP以及原生SQL查询的ID在一个数组中的查询

ThinkPHP中, 示例代码如下

$mobileId=[1,3,5,6,7,8];
$mobileRec=db('product')
           ->where('id','in',$mobileId)
           ->select();

原生SQL, 示例代码如下

select * from product where id in (6,7,8,9,10,11,12);

Posted: 八月 13th, 2019


Subscribe for email updates

发表评论

Note: Wrap all of your code blocks in <code>...</code> and replace < and > with &lt; and &gt;, respectively.