Doc #67046 [Opn->Csd]: mysqli_stmt::free_result also clears result bindings

From: Date: Wed, 09 Apr 2014 08:00:56 +0000
Subject: Doc #67046 [Opn->Csd]: mysqli_stmt::free_result also clears result bindings
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-11136@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67046&edit=1 ID: 67046 User updated by: jon dot kloske at gmail dot com Reported by: jon dot kloske at gmail dot com Summary: mysqli_stmt::free_result also clears result bindings -Status: Open +Status: Closed Type: Documentation Problem Package: MySQLi related PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Hrm... this might be a php windows thing, and may need multiple concurrent prepared statements on the same db connection to trigger. I just tried a simpler version and it didn't unbind the results. Maybe I should work on a repro condition first as this may actually be a bug rather than a documentation problem. I'm going to nuke my own report until then! Previous Comments: ------------------------------------------------------------------------ [2014-04-09 03:16:47] jon dot kloske at gmail dot com Description: ------------ --- From manual page: http://www.php.net/mysqli-stmt.free-result --- "mysqli_stmt::free_result -- mysqli_stmt_free_result — Frees stored result memory for the given statement handle" It also clears the result bindings, so that you need to call mysqli_stmt::bind_result again if you're going to use the prepared statement a second time after this. In spite of the manual for bind_result saying that it must be called after execute, this doesn't appear to actually be required in all the testing I've done. Ie, if you have a prepared statement that returns a name column based off an id, you can bind $id to the id in the parameter and $name to the name result at the end before calling execute and it seems to work fine. You can then keep changing $id and calling execute and fetch and $name gets filled correctly. If you however call free_result after the fetch (ie, if you're using store_result) the next time you run execute $name isn't bound to the result. The manual page isn't particularly clear on these unintended side effects of free_result since all it says is it frees the stored result memory, not also the bindings... ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67046&edit=1

« previous php.doc.bugs (#11136) next »