我有这个例子
function read()
{
$parameters = array();
$results = array();
$mysql = new mysqli('localhost', 'root', 'root', 'test') or die('There was a problem connecting to the database');
$stmt = $mysql->prepare('SELECT id,body,posts FROM post') or die('Problem preparing query');
$stmt->execute();
$meta = $stmt->result_metadata();
while ( $field = $meta->fetch_field() ) {
$parameters[] = &$row[$field->name];
}
call_user_func_array(array($stmt, 'bind_result'), $parameters);
while ( $stmt->fetch() ) {
$x = array();
foreach( $row as $key => $val ) {
$x[$key] = $val;
}
$results[] = $x;
}
return $results;
}
$results = read();
我想出了为什么我需要在这个例子中引用$parameters[] = &$row[$field->name];
它没有&就行不通。我在链接中找到了这个例子。你能解释一下为什么需要使用reference 和from var $row 来自。它是 fetch_field 的一部分吗?