Sunday, May 15, 2016

Stored Procedure Class For MySQL

Stored Procedure is a set of some sql statements which are stored in database server and can be executed anytime we call them.

As MySQL older than version 5 doesnt support the stored procedure functionatlity, then we have to use ST_Proc class. It can be downloaded from phpclasses.org or from here (3 kb including an example).

In this package there should be 2 main files, namely, sqlLayer.php and STProc.php. 

For practicing you should prepare a database named test with a table named test as well (just for dummy). Then create 2 fields,  id int (11) and text varchar (20). Insert some dummy data on the table.

Then create stored procedure and save it (just like in the example default.sp in the package), and create a file to call and execute it (sp.php in the example file). Execute this file to see the results.