>  기사  >  백엔드 개발  >  thinkphp 小弟我想用or 连接

thinkphp 小弟我想用or 连接

WBOY
WBOY원래의
2016-06-13 13:10:54783검색

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'

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.