Can you tell me how to run PHP functions in SQL statements to limit the results of a query?

Source: Internet
Author: User
Tags sqlite database
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
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.