Home  >  Article  >  Backend Development  >  thinkphp 小弟我想用or 连接

thinkphp 小弟我想用or 连接

WBOY
WBOYOriginal
2016-06-13 13:10:54820browse

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'

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn