1
我试图使用call_user_func_array和mysqli_stmt :: bind_param像这样的mysqli bind_params:用于插入查询
# A. prepare an insert query statement
$this->_stmt = $db_link->prepare('INSERT INTO foo (col1, col2) VALUES (?,?)');
# B. bind a placeholder array to the statement
$bound = array('col1' => null, 'col2' => null);
call_user_func_array(array($this->_stmt, 'bind_param'),
array($types_string, &$bound));
# C. while there are records, retrieve, munge, and insert
while ($row = $res->fetch_assoc()) {
$bound = transform($row); # $bound remains an array indexed as 'col1', 'col2'
$this->_stmt->execute(); # PHP Notice: Array to string conversion
}
我就要由PHP引用混淆,导致数组字符串转换。或者我没有在步骤B下正确绑定占位符数组,或者我没有在步骤C中正确指定占位符。
(以前也有类似的问题,但是我还没有找到答案。)