Ask, how to run PHP function in SQL statement to limit the result of the query?
This post was last edited by easeyoo12 on 2014-02-27 22:50:26
Please help, the role of the program is to execute the SQL, the results of the query is displayed, but if the query after the judgment displayed in the page will be a problem, the code is as follows:
$_bcache->cachesql (' Shopsearch ', ' SELECT i.itemid,m.mapapimark,m.itemid from '. Db::table (' Shopitems '). ' I left JOIN '. Db::table (' Shopmessage '). ' 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 ']);
Business coordinate data processing
$value [' x_preg1 '] = preg_replace ('/\ (/', ' ', $value [' Mapapimark ']);//Remove parentheses preceding the X-coordinate
$value [' storex '] = preg_replace ('/, (. *)/', ', $value [' X_PREG1 ']);//Remove the y-coordinate and the preceding comma, leaving only the X-coordinate
$value [' y_preg1 '] = preg_replace ('/\)/', ', $value [' Mapapimark ']);//Remove parentheses following the Y-coordinate
$value [' storeY '] = preg_replace ('/(. *),/', ', $value [' Y_PREG1 ']);//Remove the x-coordinate and the trailing comma, leaving only the Y-coordinate
$value [' juli '] = getdistance ($ClientY, $ClientX, $value [' StoreY '], $value [' Storex '], 2);
$value [' juli '] = round ($value [' Juli '],2);
if ($value [' Juli '] <= $Distance) {
$shoplist [] = $value;
}
}
This is dz inside of a piece of code, I want in where m.mapapimark!= "" In this statement, call the calculation function getdistance the query out of the Mapapimark to calculate, if the calculated result is less than $distance, only to query out the bar data, How do I write it? Thank you first.
------Solution--------------------
If you are using a SQLite database, you can not
You can write database functions, or you can filter in the result set
------Solution--------------------
Calculation suggestions are done in PHP code, and the complexity of database calculations can affect performance
------Solution--------------------
Do you understand that the complexity of PHP computing will not affect performance?
References:
calculation suggestions are done in PHP code, and the complexity of database calculations can affect performance