私はこの例を持っています
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];
なしでは機能しません。この例はリンクにあります。参照と from var $row を使用する必要がある理由を説明していただけますか。fetch_field の一部ですか?