A couple of weeks ago a friend of mine asked me how to use MySQL stored procedures with PHP’s mysqli API. Out of curiosity I asked another friend, a team lead, how things where going with their PHP MySQL project, for which they had planned to have most of their business logic in stored procedures. I got an email in reply stating something along the lines: "Our developers found that mysqli does not support stored procedures correctly. We use PDO.". Well, the existing documentation from PHP 5.0 times is not stellar, I confess. But still, that’s a bit too much… it ain’t that difficult. And, it works.
Using stored procedures with mysqli
The MySQL database supports stored procedures. A stored procedure
is a subroutine stored in the database catalog. Applications can
call and execute the stored procedure. The CALL SQL
statement is used to execute a stored procedure.
Parameter
Stored procedures can …
[Read more]