Is there a way of using functions defined in PHP in mysql? Please help.
2 Answers
Yes there is a way to accomplish what you are talking about. They are called "Stored Procedures" and you can create one using PHP and then store it on MySQL Server, this way the execution of the function will my the MySQL server's responsibility instead of the PHP Engine.
Here is a link to the MySQL documentation on Stored Procedures:
Another article on Stored Procedures ,
I don't know if this answers your question, but I figured I would give it a shot.
EDIT: Check out my comments on Tudor Constantin's answer, you CAN write stored procedures to the database using a PHP MySQL query! The stored procedures get placed in the mysql database in the "proc" table on the mysql server.
h
Comments
No, there isn't. There are some equivalent functions, but SQL (the language used by MySQL) and PHP are 2 different technologies/platforms/softwares/programming paradigms/etc and they have totally different set of instructions/principles of programming.
Instead in PostgreSQL you can write stored procedures in PHP
7 Comments
$query = "CREATE PROCEDURE p99 () SELECT * FROM $this->tbname";