When I was testing the system today, I suddenly found that the original effect was not normal , After carefully examining all the code, we found that :


The function of this code is to find the code StorePink Column in table pinkAccount Is less than people, But what this code prints out is :

SELECT * FROM StorePink WHERE id='1' AND `pinkAccount < people LIMIT 1
ThinkPHP When parsing out the original field people It's parsed into a string , So the statement reports an error .


1 The correct way is as follows

Look at the next two pieces of code where The conditions are :

where('pinkAccount','>','people') // In this case, between fields, use > separate , Express > The following is the field value, not the field

where('pinkAccount',' > people') // Here is the > With the following fields , The comparison between fields

2 Use key words whereColumn( In this method ThinkPHP6 In the user's manual )


Generated SQL The statement is as follows :

SELECT * FROM StorePink WHERE ( pinkAccount > people )