Home > PHP Framework > ThinkPHP > body text

thinkphp exp what does it mean

藏色散人
Release: 2022-12-05 11:01:58
Original
1934 people have browsed it

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.

thinkphp exp what does it mean

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
Copy after login

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';
Copy after login

However, when thinkphp processes the above conditions, it converts it into the following code:

select * from vendor where vendor_f_id = 'vendor_id'
Copy after login

In other words, vendor_id is treated as a string

The solution to the above problem is:

$condition[ 'vendor_f_id' ] = [ 'exp' , ' = vendor_id ' ];
Copy after login

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');
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template