Code abuse me times, I to code such as first love ~
Problem:
Querying a field app_date whether the data is null, the normal way we do this is:
$map Array (' eq ', ' null '); $data M ("Info") , Field ("*"), where ($map), select ()
Use echo M ("Info")->getlastsql (); Print SQL statements as follows:
SELECT ' id ', ' name ', ' create_time ', ' app_data ' from ' info ' WHERE ' app_data ' = ' NULL '
But the printed SQL statement is not what I want to do, hair, modify the test, modify the test, always do not reach the correct SQL statement I want, the following is correct:
SELECT ' id ', ' name ', ' create_time ', ' app_data ' from ' info ' WHERE ' app_data ' is NULL
The solution is always there, how to do, look at the document, go through the document in At the bottom you see something like this :
Correct judgment Method:
$map Array (' EXP ', ' is NULL ');; $data = M ("Info"), Field ("*"), where ($map), select ()
To print the SQL statement:
SELECT ' id ', ' name ', ' create_time ', ' app_data ' from ' info ' WHERE ' app_data ' is NULL
Perfect ~~~~~~~
To raise knowledge, to rise Knowledge: thinkphp framework where conditions query MySQL database If a field is empty