1、创建存储过程,列出 test 库下的所有表:
mysql>DELIMITER //mysql>CREATE PROCEDURE `yejr`()->BEGIN->SHOW TABLES;->END; //Query OK, 0 rows affected (0.12 sec)mysql>DELIMITER ;mysql>CALL yejr();+------------------+| Tables_in_test |+------------------+| yejr1 || yejr2 |+------------------+
2、用 mysqli 编写测试代码:
$mysqli = new mysqli("localhost", "root", "", "test");if (mysqli_connect_errno()) {printf("Connect failed: %s/n", mysqli_connect_error());exit();}$query = "call yejr();";if ($result = $mysqli->query( $query)) {while($row = $result->fetch_row()){printf ("find table: %s /n", $row[0]);}}$result->close();?>
结果大致如下:
find table: yejr1
find table: yejr2