Skip to content

Instantly share code, notes, and snippets.

@colshrapnel
Created April 18, 2020 14:38
Show Gist options
  • Select an option

  • Save colshrapnel/f2400437ce83a40db74998faf8d7fae7 to your computer and use it in GitHub Desktop.

Select an option

Save colshrapnel/f2400437ce83a40db74998faf8d7fae7 to your computer and use it in GitHub Desktop.
<?php
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = mysqli_connect('127.0.0.1','root','','test');
$mysqli->query("DROP PROCEDURE IF EXISTS mysqli_crash");
$mysqli->query("CREATE PROCEDURE mysqli_crash ()
BEGIN
DECLARE col TEXT;
DECLARE res CURSOR FOR SELECT 1 from dual;
OPEN res;
FETCH res INTO col;
CLOSE res;
SELECT 1 from dual;
END;");
echo "--- multi_query ---\n";
$mysqli->multi_query("call mysqli_crash()");
$result = $mysqli->store_result();
echo json_encode($result->fetch_all(MYSQLI_ASSOC)),"\n";
$mysqli->next_result();
echo "--- prepare ---\n";
$stmt = $mysqli->prepare("call mysqli_crash()");
$stmt->execute();
$result = $stmt->get_result();
echo json_encode($result->fetch_all(MYSQLI_ASSOC)),"\n";
$stmt->next_result();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment