mysqli_stmt_bind to all fields in a query?
Posted: Sat Dec 16, 2006 8:46 pm
I'm trying the method used to bind to all fields that's in the comments here: http://www.php.net/manual/en/function.m ... result.php (3rd comment down) but I get NULL on the &$array[$field->name]; part according to var_dump.
Var dump output:
Code:
Any ideas?
Var dump output:
Code: Select all
array(9) { [0]=> &object(mysqli_stmt)#10 (0) { } [1]=> &NULL [2]=> &NULL [3]=> &NULL [4]=> &NULL [5]=> &NULL [6]=> &NULL [7]=> &NULL [8]=> &NULL }Code: Select all
public function prep_bind_to_all(&$stmt)
{
$data = mysqli_stmt_result_metadata($stmt);
$count = 1; //start the count from 1. First value has to be a reference to the stmt. because bind_param requires the link to $stmt as the first param.
$fieldnames[0] = &$stmt;
while ($field = mysqli_fetch_field($data))
{
echo($field->name.'<br />');
$fieldnames[$count] = &$array[$field->name]; //load the fieldnames into an array.
$count++;
}
var_dump($fieldnames);
call_user_func_array(mysqli_stmt_bind_result, $fieldnames);
}