Database operation functions in the CI framework $ this-> db-> where () usage summary, this-db-
This example summarizes the usage of database operation functions $ this-> db-> where () in the CI framework. 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 ')