Home  >  Article  >  PHP Framework  >  thinkphp exp usage

thinkphp exp usage

步履不停
步履不停Original
2019-06-25 10:13:195404browse

thinkphp exp usage

I encountered a problem today, which is to query the data of vendor_id = vendor_f_id in the vendor table. In fact, it is very simple to use the native sql statement:

select * from  vendor where vendor_id = vendor_f_id

But , in thinkphp, for the simplicity and versatility of the code, we do not consider using the native way to query sql, but use the query map method to query

$condition[ 'vendor_f_id' ] = 'vendor_id';

However, when thinkphp handles the above conditions, it will It is converted 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 ' ]

More ThinkPHP For related technical articles, please visit the ThinkPHP Tutorial column to learn!

The above is the detailed content of thinkphp exp usage. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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