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'
展开全部
使用快捷查询
加入$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'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |