Home  >  Article  >  Backend Development  >  thinkphp多条件查询怎么写

thinkphp多条件查询怎么写

WBOY
WBOYOriginal
2016-06-23 13:47:351160browse

thinkphp多条件查询怎么写?
比如表user,字段id,name,nickname。现在根据name和adress多条件查询,$name和$nickname,两个条件是或,不是并。怎么写?
另外,如果查询条件为数组的话怎么写?比如$id=array(1,2,3),查找id为1,2,3的三条数据


回复讨论(解决方案)

1:

$a=M('user);$b=$a->where("name='你的名字' or nickname='你的昵称'")->select();

2:
$a=M('user'); $data['id']=array('in',array(1,2,3));             $b=$a->where($data)->select();  



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