How can I run a PHP function in an SQL statement to limit the query results? Please help. The purpose of the program is to execute the SQL statement first and then display the query results. However, if the query is performed and the result is displayed, the page is displayed. the code is as follows:
$ _ BCACHE-> cachesql ('shopsearch', 'Select I. itemid, m. mapapimark, m. itemid FROM '. DB: table ('shopitems '). 'I LEFT join '. DB: table ('shopessage ').'m ON I. itemid = m. itemid WHERE m. mapapimark! = "" ', 0, 1, $ tpp, 0, 'index', 'shop'); $ multipage = $ _ SBLOCK ['shopsearch _ multipage']; $ resultcount = $ _ SBLOCK ['shopsearch _ listcount']; foreach ($ _ SBLOCK ['shopsearch'] as $ value) {$ value = $ _ BCACHE-> getshopinfo ($ value ['itemid']); // merchant coordinate data processing $ value ['X _ preg1 '] = preg_replace ('/\ (/', '', $ value ['mapapimark']); // remove the brackets $ value ['storex'] = preg_replace ('/,(. *)/', '', $ value ['X _ preg1']); // remove the Y coordinate and the preceding comma, only the X coordinates $ value ['Y _ preg1 '] = preg_replace ('/\)/',', $ value ['mapapimark']) are retained; // remove the brackets $ value ['store'] = preg_replace ('/(. *),/', '', $ value ['Y _ preg1']); // remove the X coordinate and the following comma, retain only Y coordinates $ value ['juli'] = GetDistance ($ ClientY, $ ClientX, $ value ['store'], $ value ['storex'], 2 ); $ value ['juli'] = round ($ value ['juli'], 2); if ($ value ['juli'] <= $ Distance) {$ shoplist [] = $ value ;}}
This is a piece of code in DZ. I want to use WHERE m. mapapimark! = "" In this statement, call the calculation function GetDistance to calculate the queried mapapimark. if the calculated result is smaller than $ Distance, how can I write this data? Thank you.
Reply to discussion (solution)
If you are using an sqlite database, you can. Otherwise, you cannot.
You can write database functions or filter data in the result set.
It is recommended that the computing should be completed in the php code. if the database computing is complex, the performance will be affected.
Does the complexity of php computing not affect performance?
It is recommended that the computing should be completed in the php code. if the database computing is complex, the performance will be affected.