Wednesday, October 26, 2016

Create Procedure in MySQL using PHPMyAdmin

In MyPHPAdmin 4.x, there is "Add Routine" link under "Routines" tab at the top row. This link opens a popup dialog where you can write your Stored procedure without worrying about delimiter or template.
enter image description here
Add Routine
enter image description here
Note that for simple test stored procedure, you may want to drop the default parameter which is already given or you can simply set it with a value.
On PHP, you can use the following code to call the procedure.
include_once("dbconfig.php");
    $stmt = "CALL insertEmp(0;";
    $rs = $db_con -> prepare($stmt);
    $row = $rs -> execute();
?>