Skip to content

Instantly share code, notes, and snippets.

@alihammad-gist
Created February 28, 2024 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alihammad-gist/4c7a5035e778c0eced2bda3c3babab2b to your computer and use it in GitHub Desktop.
Save alihammad-gist/4c7a5035e778c0eced2bda3c3babab2b to your computer and use it in GitHub Desktop.
<?php
// Stored procedure definition
<<<SQL
DELIMITER $$
CREATE PROCEDURE get_top_customers()
BEGIN
SELECT * FROM `customers` LIMIT 4;
SELECT * FROM `orders` LIMIT 4;
END$$
DELIMITER ;
SQL;
?>
<?php
// ...redacted
// php script
$stmt = $conn->query('CALL get_top_customers()');
do {
while($row = $stmt->fetch(PDO::FETCH_NUM)) {
echo implode(", ", $row) . PHP_EOL;
}
echo "----\n";
} while($stmt->nextRowset());
?>
Output below
103, Atelier graphique, Schmitt, Carine , 40.32.2555, 54, rue Royale, , Nantes, , 44000, France, 1370, 21000.00
112, Signal Gift Stores, King, Jean, 7025551838, 8489 Strong St., , Las Vegas, NV, 83030, USA, 1166, 71800.00
114, Australian Collectors, Co., Ferguson, Peter, 03 9520 4555, 636 St Kilda Road, Level 3, Melbourne, Victoria, 3004, Australia, 1611, 117300.00
119, La Rochelle Gifts, Labrune, Janine , 40.67.8555, 67, rue des Cinquante Otages, , Nantes, , 44000, France, 1370, 118200.00
----
10100, 2003-01-06, 2003-01-13, 2003-01-10, Shipped, , 363
10101, 2003-01-09, 2003-01-18, 2003-01-11, Shipped, Check on availability., 128
10102, 2003-01-10, 2003-01-18, 2003-01-14, Shipped, , 181
10103, 2003-01-29, 2003-02-07, 2003-02-02, Shipped, , 121
----
----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment