Home  >  Article  >  Backend Development  >  thinkphp多条件查询如何写

thinkphp多条件查询如何写

WBOY
WBOYOriginal
2016-06-13 12:07:59973browse

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

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

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



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