daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Jan 24th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $link = mysqli_connect('127.0.0.1', 'login', 'password', 'db');
  2.     $sql = 'CALL procedure_name(1, 2)';
  3.     $result = mysqli_query($link, $sql);
  4.     while($row = mysqli_fetch_assoc($result)) {
  5.         var_dump($row);
  6. }
  7.    
  8. $sql = 'Call procedure_name(?, ?)';
  9. $stmt = mysqli_prepare($link, $sql);
  10. $p1 = 1;
  11. $p2 = 2;
  12. mysqli_stmt_bind_param($stmt, 'ii', $p1, $p2);
  13. mysqli_stmt_execute($stmt);
  14.    
  15. $result = mysqli_stmt_result_metadata($stmt);
  16.  $field = mysqli_fetch_field($result);
  17.    
  18. if (!($stmt = $mysqli->prepare("CALL p()"))) {
  19.     echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
  20. }
  21.  
  22. if (!$stmt->execute()) {
  23.     echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
  24. }
  25.  
  26. do {
  27.     if ($res = $stmt->get_result()) {
  28.         printf("---n");
  29.         var_dump(mysqli_fetch_all($res));
  30.         mysqli_free_result($res);
  31.     } else {
  32.         if ($stmt->errno) {
  33.             echo "Store failed: (" . $stmt->errno . ") " . $stmt->error;
  34.         }
  35.     }
  36. } while ($stmt->more_results() && $stmt->next_result());
  37.    
  38. CREATE PROCEDURE p() READS SQL DATA BEGIN SELECT id FROM test; SELECT id + 1 FROM test; END;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top