Doc #62598 [Com]: Mistake in user comment
| From: | mail+php at requinix dot net | Date: | Wed, 18 Jul 2012 19:26:57 +0000 |
| Subject: | Doc #62598 [Com]: Mistake in user comment | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-8571@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62598&edit=1
ID: 62598
Comment by: mail+php at requinix dot net
Reported by: the dot music dot of dot the dot ainur at gmail dot
com
Summary: Mistake in user comment
Status: Open
Type: Documentation Problem
Package: Documentation problem
Operating System: N/A
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Feel free to post your own comment correcting the mistake :)
Previous Comments:
------------------------------------------------------------------------
[2012-07-18 12:23:55] the dot music dot of dot the dot ainur at gmail dot com
Description:
------------
On this documument page : http://php.net/manual/fr/mysqli-stmt.bind-param.php
Last user comment (nick9v at hotmail dot com 30-Jun-2012 10:12) is very useful but contains a little
mistake.
The function
public function add( $type, $value ){
$this->values[] = $value;
$this->types .= $type;
}
Should be
public function add( $type, &$value ){
$this->values[] = $value;
$this->types .= $type;
}
Otherwise, this :
call_user_func_array( array($stm, 'bind_param'), $bindParam->get());
Will return this :
Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given
Test script:
---------------
// class BindParam copied from user comment
$bindParam = new BindParam();
$qArray = array();
$column1NewValue = $_POST['column1'];
$column2NewValue = $_POST['column1'];
$qArray[] = 'Column1 = ?';
$bindParam->add('i', $column1NewValue );
$qArray[] = 'Column2 = ?';
$bindParam->add('s', $column2NewValue );
$query = 'UPDATE myTable SET ';
$query.= implode(' , ', $qArray);
$query.= ' WHERE PKeyID= ?';
$bindParam->add('i', $lineToUpdate);
$stmt = $mysqli->prepare($query);
call_user_func_array(array($stmt, 'bind_param'), $bindParam->get());
$stmt->execute();
$stmt->close();
Expected result:
----------------
Row in database properly updated.
Actual result:
--------------
( ! ) Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in
c:\path\myfile.php on line 157
Call Stack
# Time Memory Function Location
1 0.0010 297832 {main}( ) ..\myfile.php:0
2 0.0059 322952 call_user_func_array ( ) ..\myfile.php:157
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62598&edit=1