Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- echo "<h1>Running test_procedure_1</h2>";
- echo "<pre>";
- echo "CREATE PROCEDURE `test_procedure_1`()".
- "BEGIN".
- " select 'gary';".
- " CALL raise_error;".
- "END";
- echo "</pre>";
- //connect to database
- $connection = new \PDO("mysql:host=".$db['server'].";dbname=".$db['name'].";charset=utf8", $db['user'], $db['password']);
- $stmt = $connection->prepare("CALL test_procedure_1");
- if (!($stmt->execute())) {
- echo "CALL failed: (" . $stmt->errorCode() . ") " . print_r($stmt->errorInfo(),true);
- }
- else{
- //loop the result set
- echo "RESULTS:";
- while ($row = $stmt->fetch()) {
- print_r($row);
- }
- }
- echo "<br>----------<br>";
- echo "<h1>Running test_procedure_2</h2>";
- echo "<pre>";
- echo "CREATE PROCEDURE `test_procedure_2`()".
- "BEGIN".
- " CALL raise_error;".
- " select 'gary';".
- "END";
- echo "</pre>";
- $connection = new \PDO("mysql:host=".$db['server'].";dbname=".$db['name'].";charset=utf8", $db['user'], $db['password']);
- $stmt = $connection->prepare("CALL test_procedure_2");
- if (!($stmt->execute())) {
- echo "CALL failed: (" . $stmt->errorCode() . ") " . print_r($stmt->errorInfo(),true);
- }
- else{
- //loop the result set
- echo "RESULTS:";
- while ($row = $stmt->fetch()) {
- print_r($row);
- }
- }
- echo "<br>----------<br>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement