How can I run the PHP function in an SQL statement to limit the query results?

Source: Internet
Author: User
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.

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.