Heim  >  Artikel  >  Backend-Entwicklung  >  thinkphp 小弟我想用or 连接

thinkphp 小弟我想用or 连接

WBOY
WBOYOriginal
2016-06-13 13:10:54783Durchsuche

thinkphp 我想用or 连接
在不
我想问一下
select * from table where id=2 or pid =2

夏草 15:05:10
我想得到上面的语句

我这样写
$map['id'] = '1';
$map['pid'] = '2';
$modle->where($map)->select();

得么的是 and 连起来的

我怎么写一下这个数组呢


------解决方案--------------------
我想,手册中说的很清楚了:
更改默认的逻辑判断,通过使用 _logic 定义查询逻辑
$condition['name'] = 'thinkphp';
$condition['account'] = 'thinkphp';
$condition['_logic'] = 'OR';
// 把查询条件传入查询方法
$User->where($condition)->select(); 

最后生成的SQL语句是
SELECT * FROM think_user WHERE `name`='thinkphp' OR `account`='thinkphp'

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn