note 106418 added to mysqli-stmt.bind-param
| From: | OleClausen at osu1 dot php dot net | Date: | Tue, 08 Nov 2011 19:19:08 +0000 |
| Subject: | note 106418 added to mysqli-stmt.bind-param | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184333@lists.php.net to get a copy of this message | ||
Due to changes in PHP 5.3 I encountered a problem with 'bind_param' in my iQuery function
below. The values in the passed array *must* be references. The soloution is this function:
function getRefArray($a) {
if (strnatcmp(phpversion(),'5.3')>=0) {
$ret = array();
foreach($a as $key => $val) {
$ret[$key] = &$a[$key];
}
return $ret;
}
return $a;
}
- and this change in iQuery:
if ($stmt = $mysqli->prepare($sql)) {
$arrParams = getRefArray($arrParams); // <-- Added due to changes since PHP 5.3
$method = new ReflectionMethod('mysqli_stmt', 'bind_param');
$method->invokeArgs($stmt, $arrParams);
$stmt->execute();
$meta = $stmt->result_metadata();
----
Server IP: 66.207.199.35
Probable Submitter: 90.184.94.109
----
Manual Page -- http://www.php.net/manual/en/mysqli-stmt.bind-param.php
Edit -- https://master.php.net/note/edit/106418
Del: integrated -- https://master.php.net/note/delete/106418/integrated
Del: useless -- https://master.php.net/note/delete/106418/useless
Del: bad code -- https://master.php.net/note/delete/106418/bad+code
Del: spam -- https://master.php.net/note/delete/106418/spam
Del: non-english -- https://master.php.net/note/delete/106418/non-english
Del: in docs -- https://master.php.net/note/delete/106418/in+docs
Del: other reasons-- https://master.php.net/note/delete/106418
Reject -- https://master.php.net/note/reject/106418
Search -- https://master.php.net/manage/user-notes.php