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 ')