I am trying to create an associative array from the results of a mysql query using mysqli stmt class. I want an array of associative arrays just like mysql_fetch_assoc() is used here:
PHP Code:
      $results = array();
      while(
$row $result->fetch_assoc())
      {
         
array_push($results,$row);
      } 
Here is what I've got so far:
PHP Code:
  if(!$stmt->execute())                                                             
    return;                                                                         

  
$data $stmt->result_metadata();                                                 
  
$fields = array();                                                                
  
$row = array();
  
$rows = array();                                                                  

  
$fields[0] = &$stmt;                                                              
  
$count 1;                                                                       
  
// this dynamically creates an array where each key is the name of the field.
  
while($field mysqli_fetch_field($data)) {                                       
    
$fields[$count] = &$row[$field->name];                                          
    
$count++;                                                                       
  }

// this calls bind_result() to each member of this $row array 
  
call_user_func_array(array($stmt,'bind_result'), $row);       //<--problem                     
  
while($stmt->fetch())
    
array_push($rows,$row);                                                         

  
$results = (count($rows) == 0) ? false $rows;                                   
  
print_r($results);                                                                

  
$stmt->close(); 
This will put the last record of the result into the array as many times as there are records.
Array
(
[0] => Array
(
[id] => 2
[name] => Joe
[occupation] => Virtual Realtor
)

[1] => Array
(
[id] => 2
[name] => Joe
[occupation] => Virtual Realtor
)

)

I think the problem is that I can't use the same variables for binding each record. So I can't use the same elements of the same array for each row. So how would I work around this? I can't dynamically create and unset an array in the while(fetch) loop because I can't call fetch until the variables are bound. I pulled and modified some of this code from http://us3.php.net/manual/en/mysqli-...ind-result.php