Re: Call PHP script from MySQL
| From: | Colin Guthrie | Date: | Tue, 19 Feb 2008 09:38:02 +0000 |
| Subject: | Re: Call PHP script from MySQL | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269594@lists.php.net to get a copy of this message | ||
Mário Gamito wrote:
> Hi,
>
> Is it possible to call from within MySQL an external PHP script ?
> I've read "MySQL Stored Procedure Programming" from O'Reilly but found
> nothing :(
>
> How can I do this ?
>
> Any help would be appreciated.
Could be that a Trigger does what you want?
http://dev.mysql.com/doc/refman/5.0/en/triggers.html
But I'd suspect that you probably want to use a MySQL function to do this:
e.g. SELECT SYSTEM('/usr/bin/php /path/to/my/script');
I'm not 100% sure if such a function exists, but if not it's would be a
fairly trivial UDF to implement:
http://dev.mysql.com/doc/refman/5.0/en/adding-udf.html
I'd be very careful tho', as creating such a UDF opens up a potential
minefield for SQL injection attacks!! If it's only one script you want
to execute, then it would be better to create a specific function that
calls that and only that and doesn't accept arguments and doesn't have
any nasty side affects if it's run in an ad-hoc manner.
There may be better solutions and it may be that this could be
implemented in other way if you look at it differently.
Col