Advertisement
karlokokkak

Untitled

Apr 4th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. function get_result( $Statement) {
  2.     $RESULT = array();
  3.     $Statement->store_result(); *Line 5* <--
  4.     for ( $i = 0; $i < $Statement->num_rows; $i++ ) {
  5.         $Metadata = $Statement->result_metadata();
  6.         $PARAMS = array();
  7.         while ( $Field = $Metadata->fetch_field() ) {
  8.             $PARAMS[] = &$RESULT[ $i ][ $Field->name ];
  9.         }
  10.         call_user_func_array( array( $Statement, 'bind_result' ), $PARAMS );
  11.         $Statement->fetch();
  12.     }
  13.     return $RESULT;
  14. }
  15.  
  16. $link = new mysqli("localhost","user","123","database");
  17.  
  18. // Check connection
  19. if($link === false){
  20.     die("ERROR: Could not connect. " . mysqli_connect_error());
  21. }
  22.  
  23. $sql = "SELECT * FROM job_book";
  24. $query = $link->prepare($sql);
  25. $query->execute();
  26.  
  27. $RESULT = get_result($query);
  28.  
  29. print_r( $RESULT );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement