thinkphp operator vs . SQL operator Table |
TP operator |
SQL operator |
Sample Example |
Actual query conditions |
eq |
= |
$map [' id '] = array (' eq ', 100); |
Equivalent to:$map [' id '] = +; |
Neq |
!= |
$map [' id '] = array (' NEQ ', 100); |
ID! = 100 |
Gt |
> |
$map [' id '] = array (' GT ', 100); |
ID > 100 |
Egt |
>= |
$map [' id '] = array (' EGT ', 100); |
ID >= 100 |
Lt |
< |
$map [' id '] = array (' lt ', 100); |
ID < 100 |
Elt |
<= |
$map [' id '] = array (' ELT ', 100); |
ID <= 100 |
Like |
Like |
$map < ' username ' > = array (' Like ', ' admin% '); |
Username like ' admin% ' |
Between |
Between and |
$map [' id '] = array (' Between ', ' 1,8 '); |
ID between 1 and 8 |
Not between |
Not between and |
$map [' id '] = array (' Not between ', ' 1,8 '); |
ID not between 1 and 8 |
Inch |
Inch |
$map [' id '] = array (' In ', ' 1,5,8 '); |
ID in (1,5,8) |
Not in |
Not in |
$map [' id '] = array (' Not ', ' 1,5,8 '); |
ID not in (1,5,8) |
and(default) |
and |
$map [' id '] = Array (array (' GT ', 1), Array (' LT ', 10)); |
(ID > 1) and (ID < 10) |
Or |
Or |
$map [' id '] = array (' GT ', 3), array (' LT ', ten), ' or '); |
(ID > 3) OR (ID < 10) |
XOR(different or) |
Xor |
Only one of the two inputs is true . The result is true, otherwise false, the sample is slightly. |
1 XOR 1 = 0 |
Exp |
Synthetic expressions |
$map [' id '] = Array (' exp ', ' in (1,3,8) '); |
$map [' id '] = array (' In ', ' 1,3,8 '); |
Or |
Different fields or |
$map [' id '] = ' 8 '; $map [' pid '] = ' 10 '; $map [' _logic '] = ' OR '; |
' ID ' =8 and ' pid ' =10 |
Additional Information
· Like SQL , thethinkphp operator does not differentiate between uppercase and lowercase. eq is the same as EQ.
· Between, in conditions support strings or arrays, that is, the following two formulations are equivalent:
$map [' id '] = array (' Not ', ' 1,5,8 ');
$map [' id '] = array (' Not in ', Array (' 1 ', ' 5 ', ' 8 '));
·
ExpAn expression
The exp in the above table is not an operator. Instead, it is a composite expression to support more complex conditional settings.
Exp operation conditions are not treated as strings. The ability to use whatever SQL supports syntax. Contains the use of functions and field names.
Exp is not only used for where conditions, but also for data updates, such as:
$Dao = M ("article");
Build the data array for save, article PV number +1
$data [' id '] = ten, $data [' counter '] = Array (' exp ', ' counter+1');
Save changed data according to conditions
$User->save ($data);
thinkphp Whereusing expressions in conditions
SOURCE : http://www.cnblogs.com/martin1009/archive/2012/08/24/2653718.html
thinkphp operator vs. sql operator table