xxxxxxxxxx
-- Basic example [mySQL]
DELIMITER &&
CREATE PROCEDURE Users()
BEGIN
SELECT * FROM users;
END &&
DELIMITER ;
CALL Users()
-- Example with parameters
DELIMITER &&
CREATE PROCEDURE getUser(inputID int)
BEGIN
SELECT * FROM users
WHERE user_ID = inputID;
END &&
DELIMITER ;
CALL getUser(1)
xxxxxxxxxx
DELIMITER $$
DELIMITER $$
CREATE PROCEDURE SpGetAllStudents()
BEGIN
select * from students;
END $$
DELIMITER ;
#CALL SpGetAllStudents(); // calling the sp
#DROP PROCEDURE SpGetAllStudents; // deleting the sp
// call using php
$conn = mysqli_connect("hostname", "user", "password", "db", "port");
//run the store proc
$result = mysqli_query($conn, "CALL SpGetAllStudents");
//loop the result set
$rows = mysqli_fetch_assoc($result);
print_r($rows);