Database operation functions in the CI framework $ this-> db-> where () usage summary

Source: Internet
Author: User
This article mainly introduces the usage of database operation functions $ this-db-where () in the CI framework, and analyzes or_where (), where_in (), or_where_in () based on examples () tips for using functions such as where_not_in () and or_where_not_in (). For more information about database operation functions in the CI framework, see the following example: $ this-> db-> where () related usage. We will share this with you for your reference. The details are as follows:

CI framework database operation function this-> db-> where () usage

1) $ this-> db-> where ('match (field) AGAINST ("value") ', NULL, FALSE)

If you set the optional third parameter $ this-> db-> where () to FALSE, CodeIgniter will not protect the field names or table names that contain the backslash.

2) $ this-> db-> or_where ()

This function is almost identical to the one above. The only difference is that the clauses generated by this function are connected by OR:

$ This-> db-> where ('name! = ', $ Name); $ this-> db-> or_where ('Id>', $ id); // Generate: WHERE name! = 'Job' OR id> 50

Note: or_where () was previously called orwhere (), and the latter is outdated.

3) $ this-> db-> where_in ();

Generate a WHERE field IN ('item', 'ITEM') query statement. if appropriate, connect it with AND.

$ Names = array ('Frank ', 'Todd', 'James '); $ this-> db-> where_in ('username', $ names); // generate: WHERE username IN ('Frank ', 'Todd', 'James ')

4) $ this-> db-> or_where_in ();

Generate a WHERE field IN ('item', 'ITEM') query statement. if appropriate, connect it with OR.

$ Names = array ('Frank ', 'Todd', 'James '); $ this-> db-> or_where_in ('username', $ names); // generate: OR username IN ('Frank', 'Todd ', 'James ')

5) $ this-> db-> where_not_in ();

Generate a WHERE field not in ('item', 'ITEM') query statement. if appropriate, connect it with AND.

$ Names = array ('Frank ', 'Todd', 'James '); $ this-> db-> where_not_in ('username', $ names); // generate: WHERE username not in ('Frank ', 'Todd', 'James ')

6) $ this-> db-> or_where_not_in ();

Generate a WHERE field not in ('item', 'ITEM') query statement. if appropriate, connect it with OR.

$ Names = array ('Frank ', 'Todd', 'James '); $ this-> db-> or_where_not_in ('username', $ names); // generate: OR username not in ('Frank ', 'Todd', 'James ')

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.