note 109190 deleted from mysqli-stmt.store-result by danbrown

From: Date: Tue, 26 Jun 2012 19:50:14 +0000
Subject: note 109190 deleted from mysqli-stmt.store-result by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-188878@lists.php.net to get a copy of this message
Note Submitter: rejohns at post dot harvard dot edu ---- The below note says to use the following order when using store_result; $stmt = $mysqli->prepare("SELECT $column FROM $table") ; $stmt->execute(); $stmt->store_result(); // Fetch a record. Bind the result to a variable called 'value' and fetch. $stmt->bind_result($value) ; $res = $stmt->fetch() ; This seems to be categorically false at least on both servers I use under PHP 5.2. Using store_result and execute before bind_result gave me all sorts of phantom problems with text fields being clipped to one character. Not on every query, but consistently on some queries and only in some scripts. After changing the order to that given in the documentation for execute to $stmt = $mysqli->prepare("SELECT $column FROM $table") ; // Fetch a record. Bind the result to a variable called 'value' and fetch. $stmt->bind_result($value) ; $stmt->execute(); $stmt->store_result(); $res = $stmt->fetch() ; Everything works perfectly. I only spent nine hours attempting a fix for this on a live website for the company I work for searching through memory usage and all sorts of other places trying to track down this phantom bug so I thought this might be useful to someone. Interestingly PHP 5.3 has no problems at all doing it either way when I've tested it.

« previous php.notes (#188878) next »