Thinkphp I want to use or to connect. if not, I want to ask select * fromtablewhereid = 2 orpid = 2 Cordyceps 15:05:10. I want to get the above statement. I want to write $ map ['id'] = '1 like this. '; $ map ['pid '] = '2'; $ modle-thinkphp I want to connect with or
Do not
I 'd like to ask
Select * from table where id = 2 or pid = 2
Xianxiao 15:05:10
I want to get the above statement
I write it like this
$ Map ['id'] = '1 ';
$ Map ['pid '] = '2 ';
$ Modle-> where ($ map)-> select ();
Is it and?
How can I write this array?
------ Solution --------------------
I think it is clear in the manual:
Change the default logic judgment by using _ logic to define the query logic
$ Condition ['name'] = 'thinkphp ';
$ Condition ['account'] = 'thinkphp ';
$ Condition ['_ logic'] = 'OR ';
// Pass the query condition into the query method
$ User-> where ($ condition)-> select ();
The last generated SQL statement is
SELECT * FROM think_user WHERE 'name' = 'thinkphp' OR 'account' = 'thinkphp'
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.