A quick query method (| and &) in ThinkPHP3.0 &)

Source: Internet
Author: User
1. implement the same query condition for different fields $ UserM (& quot; User & quot;); // instantiate the User object $ map [& amp; #39; name | title & amp; #39;] & amp; #39; thinkphp & amp; #39; // pass the query conditions to the queryer...

1. implement the same query conditions for different fields

  1. $ User = M ("User"); // instantiate the User object
  2. $ Map ['name | title'] = 'thinkphp ';
  3. // Pass the query condition into the query method
  4. $ User-> where ($ map)-> select ();

The query condition becomes name = 'thinkphp' OR title = 'thinkphp'

2. implement different query conditions for different fields

  1. $ User = M ("User"); // instantiate the User object
  2. $ Map ['status & title'] = array ('1', 'thinkphp', '_ multi' => true );
  3. // Pass the query condition into the query method
  4. $ User-> where ($ map)-> select ();
  5. '_ Multi' => true must be added at the end of the array, indicating that the current multi-condition match is performed. in this way, the query condition becomes status = 1 AND title = 'thinkphp ', more query fields are supported, for example:
  6. $ Map ['status & score & title'] = array ('1', array ('GT ', '0'), 'thinkphp ', '_ multi' => true );

The query condition changes to status = 1 AND score> 0 AND title = 'thinkphp'

Note:"|" And "&" cannot be used at the same time in the shortcut query method.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.