1. common query method a and string: $ arr $ m-& gt; where (& quot; sex0andusername & amp; #39; gege & amp; #39; & quot ;) -& gt; find (); // the string must be enclosed in quotation marks B, array $ data [& amp; #39; sex & amp; #3...
I. common query method
A. string: $ arr = $ m-> where ("sex = 0 and username = 'gege'")-> find (); // enclose the string with quotation marks.
B. array
- $ Data ['sex'] = 0;
- $ Data ['username'] = 'gege ';
- $ Arr = $ m-> where ($ data)-> find (); // transmits the previous array for query. this method defaults to the and (and) relationship.
Note: If the or relationship is used, you need to add an array value.
- $ Data ['sex'] = 0;
- $ Data ['username'] = 'gege ';
- $ Data ['_ logic'] = 'or'; // add a _ logic value to the array as an or relationship.
II. expression query method
- $ Data ['id'] = array ('Lt ', 6); // the array element is still an array
- $ Arr = $ m-> where ($ data)-> select ();
- EQ = // case insensitive
- NEQ is not equal
- GT>
- EGT greater than or equal
- LT is less
- ELT less than or equal
- LIKE fuzzy query
- $ Data ['username'] = array ('like', '% ge %'); // like
- $ Arr = $ m-> where ($ data)-> select (); // All records containing ge are queried.
- NOTLIKE does not contain
- $ Data ['username'] = array ('notlike', '% ge %'); // There is no space in the notlike Center
- $ Arr = $ m-> where ($ data)-> select ();
-
- Note: If a field matches multiple wildcards
- $ Data ['username'] = array ('like', array ('% ge %', '% 100',' % 5% '),' and '); // if there is no third value and, the default relationship is or.
- $ Arr = $ m-> where ($ data)-> select (); // or (or) you can find one of the values.
-
- BETWEEN
- $ Data ['id'] = array ('between', array (5, 7 ));
- $ Arr = $ m-> where ($ data)-> select ();
- // SELECT * FROM 'TP _ user' WHERE ('id' BETWEEN 5 AND 7 ))
- $ Data ['id'] = array ('not between', array (5, 7); // note that spaces must exist between not and.
- $ Arr = $ m-> where ($ data)-> select ();
- IN
- $ Data ['id'] = array ('in', array (4,6, 7 ));
- $ Arr = $ m-> where ($ data)-> select ();
- // SELECT * FROM 'TP _ user' WHERE ('id' IN (4,6, 7 ))
-
- $ Data ['id'] = array ('not in', array (, 7 ));
- $ Arr = $ m-> where ($ data)-> select ();
- // SELECT * FROM 'TP _ user' WHERE ('id' not in (4,6, 7 ))