Home > PHP Framework > ThinkPHP > body text

thinkphp exp usage

步履不停
Release: 2019-06-25 10:13:19
Original
5426 people have browsed it

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

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

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'
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

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!

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