Jump to content

using php functions in a query string


jumpenjuhosaphat

Recommended Posts

Is it possible.  Say I have a function....distance_between, which takes 2 postal area strings and returns a number that represents the distance between to locations.  Could I then use that function within a string like follows:

[code]
SELECT * FROM ads WHERE distance_between(location1, location2)<500
[/code]

It should be noted that location1 is a value that should be pulled out of the table while doing the query, and location2 is predetermined by the user.
Link to comment
https://forums.phpfreaks.com/topic/35777-using-php-functions-in-a-query-string/
Share on other sites

no man, you can not do that. 

However, you can add a function into mysql for it to work with mysql.
This function must be written in C/C++, and technically, I have never done anything like this but you can research it here:
http://dev.mysql.com/doc/refman/5.0/en/adding-udf.html

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.