WL#4265: External Language Plugin: PHP

Affects: Server-9.x   —   Status: Un-Assigned

LANGUAGE PHP for External Language Stored Procedures ( WL#820 )
------------  
  
The MySQL Reference Manual says:  
  
"A framework for external stored procedures will be introduced  
 in the near future. This will allow you to write stored procedures  
 in languages other than SQL. Most likely, one of the first languages  
 to be supported will be PHP because the core PHP engine is small,  
 thread-safe, and can easily be embedded. Because the framework will  
 be public, it is expected that many other languages will also be  
 supported."  
  
I guess that means we take LANGUAGE PHP seriously.  
There has been some discussion about this option  
with Zeev Suraski of Zend. These are Monty's comments:  
"  
One language that could be of specific interest for us (apart from PSMs)  
is PHP. PHP is fairly RAM-efficient, is easy to learn, executes fast and  
has powerful features. It is also thread safe. All this makes it an  
excellent choice from the point of view of our MySQL design principles.  
Whether we would need to do work for this ourselves, or simply provide  
support for others integrating the Zend PHP engine, is another issue for  
investigation. Our contacts with the Zend company can be helpful here.  
... We have been talking with the Zend people about this for 2-3 years  
and we are both very interested todo this. I still think that it's better  
to first start with embedded Python as this is a small well defined  
multi-thread safe library that seems to suit our requirements very well.  
"  
  
Currently it is possible to load a PHP library as a  
MySQL UDF, and call PHP functions within SQL statements  
with SQL values as arguments. However, it's not possible  
for the PHP function to include an SQL statement so that  
it can access the database. Implementations for MySQL are:  
"myphp" http://www.sklar.com/page/article/myphp  
"PHP functions 4 MySQL" http://www.fastflow.it/myphp/  
"Class: MySQL SP" www.phpclasses.org/browse/package/1579.html  
  
The author of myphp says it is based on Edin Kadribasic's  
PHP embed SAPI module. A certain "Matt W" (Matt Wagner?) commented:  
"  
myphp looks like it's pretty slow going by the times reported in the  
examples. :-/ Probably something to do with all that PHP junk loaded  
into MySQL. :-)  
"  
  
The PostgreSQL implementation is plPHP,  
http://plphp.commandprompt.com/  
  
Oracle has no implementation but, in response to a question  
at the PHP2004 conference, an Oracle speaker (Richard Rendell)  
said they were seriously considering it.