How can I run a PHP function in an SQL statement to limit the query results? This post was last edited by easeyoo12 from 2014-02-2722: 50: 26. please help. The purpose of the program is to execute the SQL statement and then display the query results, however, if the page is displayed after the query, the code is as follows: $ _ BCACHE-& gt; cachesql, in SQL statements, how does one run PHP functions to limit query results?
This post was last edited by easeyoo12 at 22:50:26
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 before the X coordinate
$ Value ['storex'] = preg_replace ('/,(. *)/', '', $ value ['X _ preg1']); // remove the Y coordinate and the preceding comma, and retain only the X coordinate.
$ Value ['Y _ preg1 '] = preg_replace ('/\)/', '', $ value ['mapapimark']); // remove the parentheses behind Y coordinates
$ Value ['store'] = preg_replace ('/(. *),/', '', $ value ['Y _ preg1']); // remove the X coordinate and the following comma, and retain only the Y coordinate.
$ 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.
------ 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.
------ Solution --------------------
It is recommended that the computing should be completed in the php code. if the database computing is complex, the performance will be affected.
------ Solution --------------------
Does the complexity of php computing not affect performance?
Reference:
It is recommended that the computing should be completed in the php code. if the database computing is complex, the performance will be affected.