thinkphp exp is a comprehensive expression to support more complex condition settings. The operating conditions of exp will not be treated as strings. Any syntax supported by SQL can be used, including the use of function and field names; exp is not only Used for where conditions, and can also be used for data updates.
The operating environment of this tutorial: Windows 7 system, ThinkPHP version 5, Dell G3 computer.
thinkphp exp What does it mean?
exp query in ThinkPHP
select * from vendor where vendor_id = vendor_f_id
In thinkphp, for the simplicity and versatility of the code, we do not consider using the native method for sql query, but use the map query method. Query
$condition[ 'vendor_f_id' ] = 'vendor_id';
However, when thinkphp processes the above conditions, it converts it into the following code:
select * from vendor where vendor_f_id = 'vendor_id'
In other words, vendor_id is treated as a string
The solution to the above problem is:
$condition[ 'vendor_f_id' ] = [ 'exp' , ' = vendor_id ' ];
exp expression
exp is not an operator, but a comprehensive expression to support more For complex condition settings, exp operation conditions will not be treated as strings, and any syntax supported by SQL can be used, including using function and field names.
exp is not only used for where conditions, but also for data updates
$model = M('news'); //文章的浏览数 + 1 $data['browse'] = array('exp', 'browse + 1');
Recommended learning: "thinkPHP Video Tutorial"
The above is the detailed content of thinkphp exp what does it mean. For more information, please follow other related articles on the PHP Chinese website!