Definition:
What is Store Procedure: Store Procedure is the database object.
Store procedure is pre-compiled code. By using store procedure we are able to call the functions. Store procedure is the
HOW TO CREATE STORE PROCEDURE:
Write and execute below code in mysql.
What is Store Procedure: Store Procedure is the database object.
Store procedure is pre-compiled code. By using store procedure we are able to call the functions. Store procedure is the
HOW TO CREATE STORE PROCEDURE:
Write and execute below code in mysql.
DELIMITER $$
CREATE PROCEDURE procedurename()
BEGIN
SELECT columnname1, columnname2 FROM Database.table ;
END
$$
DELIMITER
;
HOW TO CALL THE STORE PROCEDURE TO PHP using PDO:
include 'pdodatabase.php';
$sql="CALL procedurename";
try{
$stmt=$databaseobject->prepare($sql);
$stmt->execute();
$result=$stmt->fetchAll();
$stmt->execute();
$result=$stmt->fetchAll();
}
catch(exception $e){
exit;
}
foreach($result as $rs){
echo $r["columnname1"];
}
catch(exception $e){
exit;
}
foreach($result as $rs){
echo $r["columnname1"];
}