thinkPHP MySQL查询语句生成问题!
$map['receiverid']=session('uid');$map['id']=array('in',implode(",",$idset));M('messa...
$map['receiverid'] = session('uid');
$map['id'] = array('in', implode(",",$idset));
M('message') -> where($map);
假如我这样的数组会出现
WHERE `receiverid` = 1 AND `id` IN ('13','12','10','9')
但我想用OR就是或的话,请问要怎么改:WHERE `receiverid` = 1 or `id` IN ('13','12','10','9')
谢谢大家。
是thinkPHP中的谢谢~ 展开
$map['id'] = array('in', implode(",",$idset));
M('message') -> where($map);
假如我这样的数组会出现
WHERE `receiverid` = 1 AND `id` IN ('13','12','10','9')
但我想用OR就是或的话,请问要怎么改:WHERE `receiverid` = 1 or `id` IN ('13','12','10','9')
谢谢大家。
是thinkPHP中的谢谢~ 展开
2个回答
展开全部
使用快捷查询
加入$map['_logic'] = 'OR';
或
$map['id|receiverid'] = array(session('uid'),array('in', implode(",",$idset)),'_multi'=>true);
以上方法等效。
当且与或并存时可以用复合查询,如以下多了一个name
$map['receiverid'] = session('uid');
$map['id'] = array('in', implode(",",$idset));
$map['_logic'] = 'OR';
$where['name'] = 'abc';
$where['_complex'] = $map;
M('message') -> where($where)->select();
将生成:
WHERE (`receiverid` = 1 OR `id` IN ('13','12','10','9')) AND `name`='abc'
加入$map['_logic'] = 'OR';
或
$map['id|receiverid'] = array(session('uid'),array('in', implode(",",$idset)),'_multi'=>true);
以上方法等效。
当且与或并存时可以用复合查询,如以下多了一个name
$map['receiverid'] = session('uid');
$map['id'] = array('in', implode(",",$idset));
$map['_logic'] = 'OR';
$where['name'] = 'abc';
$where['_complex'] = $map;
M('message') -> where($where)->select();
将生成:
WHERE (`receiverid` = 1 OR `id` IN ('13','12','10','9')) AND `name`='abc'
ZESTRON
2024-09-04 广告
2024-09-04 广告
在Dr. O.K. Wack Chemie GmbH,我们高度重视ZESTRON的表界面分析技术。该技术通过深入研究材料表面与界面的性质,为提升产品质量与可靠性提供了有力支持。ZESTRON的表界面分析不仅涵盖了相变化、化学反应、吸附与解吸...
点击进入详情页
本回答由ZESTRON提供
展开全部
使用快捷查询
加入$map['_logic'] = 'OR';
或$map['id|receiverid'] = array(session('uid'),array('in', implode(",",$idset)),'_multi'=>true);以上方法等效。
当且与或并存时可以用复合查询,如以下多了一个name
$map['receiverid'] = session('uid');
$map['id'] = array('in', implode(",",$idset));
$map['_logic'] = 'OR';
$where['name'] = 'abc';
$where['_complex'] = $map;
M('message') -> where($where)->select();
将生成:WHERE (`receiverid` = 1 OR `id` IN ('13','12','10','9')) AND `name`='abc'
加入$map['_logic'] = 'OR';
或$map['id|receiverid'] = array(session('uid'),array('in', implode(",",$idset)),'_multi'=>true);以上方法等效。
当且与或并存时可以用复合查询,如以下多了一个name
$map['receiverid'] = session('uid');
$map['id'] = array('in', implode(",",$idset));
$map['_logic'] = 'OR';
$where['name'] = 'abc';
$where['_complex'] = $map;
M('message') -> where($where)->select();
将生成:WHERE (`receiverid` = 1 OR `id` IN ('13','12','10','9')) AND `name`='abc'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |