mysql> DELIMITER //
mysql> CREATE PROCEDURE test1()
-> BEGIN
-> SELECT * FROM user;
-> SELECT * FROM userAccount;
-> END
-> //
Query OK, 0 rows affected (0.03 sec)
mysql> DELIMITER ;
mysql>
<?php
try {
$pdo = new PDO('mysql:host=localhost;dbname=test', 'root', '');
$sql = 'call test1()';
$stmt = $pdo->query($sql);
$rowset = $stmt->fetchAll(PDO::FETCH_ASSOC);
var_dump($rowset);
echo '<hr color="red">';
$stmt->nextRowset();
$rowset = $stmt->fetchAll(PDO::FETCH_ASSOC);
var_dump($rowset);
} catch (PDOException $e) {
echo $e->getMessage();
}
?>
Paste_Image.png
网友评论