I'm trying to use call_user_func_array and mysqli_stmt::bind_param like so:
# 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
}
I'm getting confused by PHP references, leading to the array to string conversion. Either I'm not binding the placeholder array correctly under step B, or I'm not assigning to the placeholder correctly in step C.
(Similar questions have been asked before, but I haven't found an answer to mine.)