在线工具 在线编程 在线白板 在线工具 在线编程 在线白板

thinkphp如何按条件查询同表中的多条数据!

$new = M('wujiang');
$data['id'] = 1;
$news = $new->where($data)->select();
我现在只会这样的普通查询,但是我现在想查询 ‘wujiang’表中id分别为 3,6,7,12,34,的数据,我怎么能把这些id字段下的数据同时查出来呢?
最新回答
安非他命

2025-03-02 03:24:34

$data['id'] = array('IN',array(3,6,7,12,34));
$news=$new->where($data)->select();

相当于 select * from wujiang where id in(3,6,7,12,34)
重温那逝去的记忆

2025-03-02 02:03:58

$new = M('wujiang');

$data['id'] =array('eq',array(3,6,7,12,34),'OR');
$news = $new->where($data)->select();
测试下对么