I am currently running a script that pulls back transaction data (one line for each transaction) from a database with the following SQL script, which is being run in MySQL Workbench.
SELECT
id,
merchant_id,
affiliate_id,
date,
sale_amount,
commission,
ip
FROM transactions.transaction201505
One of the columns in the table t.transactions is IP address. Is there a way to embed this PHP script (or a function to this effect) within an SQL script: php function geoip_country_name_by_addr
http://php.net/manual/en/function.geoip-country-code-by-name.php
I have seen many examples of adding MySQL to PHP but would like to essentially add in Country/ City of sale to my data the other way around, so that the result could look like the sample below, which could be run off a tool such as MySQL Workbench. I don't have access to run PHP scripts on this database, and therefore need a solution with SQL.
Thanks in advance for any help you can offer on this.
Jamie
No, this is not directly possible. You could write a UDF (user define function) in an exteranl module (eg a .DLL, .so or .dylib) but using PHP in such a module is probably not possible either (because PHP is a scripting language and you would need to compile your UDF into binary code). However, MySQL has a number of built-in functions ( https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html ). Even though not what you want here.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.