2

Having an issue with prepared statement where no results are returned. Upon examining MySql's general query log, I can see where the connection is being made, but there never appears to be a query executed.

After adding mysqli_report(MYSQLI_REPORT_ALL), the following error message is returned:

Unknown prepared statement handler (4) given to mysqld_stmt_execute

The following is the code executing the prepared statement:

$something_in = 'a-string-of-text';

if($stmt = $this->prepare("SELECT first, last, phone FROM people WHERE something=? ORDER BY last ASC")){

   try{

       if (!$stmt->bind_param('s', $something_in)) {
          die('bind_param() failed: ' . htmlspecialchars($stmt->error));
        } 

       $stmt->execute();
       $stmt->bind_result($first, $last, $something, $phone);

       while($stmt->fetch()){

           $returnArray[] = array(
               'first_name'    => $first,
               'last_name'     => $last,
               'something'     => $something,
               'phone'         => $phone
           );

       }

       $stmt->free_result();
       $stmt->close();

       return $returnArray; // we make it to here with a blank array instead of expected results

   } catch (Exception $ex) {

       return $ex->getMessage();

   }

}

Has anyone else run into this issue? It seems rather odd.

MySQL Version: 5.6

PHP Version: 7

Also another useful piece of information would be that we're using netscaler which acts as a proxy between our app servers and database servers. I'm inclined to believe this might be where the hangup is happening.

EDIT

Confirmed this is in relation to our netscaler proxy as connecting app server directly to db server resolves the issue. Will post solution once cause determined.

4

1 回答 1

0

尚未确定针对这种特殊边缘情况的解决方案。然而,离开mysqli和使用 php 的PDO库已经解决了短期内的困境。

于 2018-03-21T20:00:40.857 回答