Lately I ve stumbled upon an error in a lib that used to work just fine, and I ll be damned if I can figure out where it is.
The code sample is below, and I apologize for the debug stuff that s inside it, but I m trying to get it to work.
The problem is that $temp is an array with correct key (the name of the columns) but all the values are NULL.
I think the problem lies in the
call_user_func_array(array($query, bind_result ), $params);
bit, but can t really wrap my head around it.
public function fetchRows(){
error_reporting(E_ALL+E_NOTICE);
$args = func_get_args();
$sql = array_shift($args);
traceVar($sql, "Query");
$colTypes = array_shift($args);
if (!$query = $this->prepare($sql, $colTypes)) {
die( Please check your sql statement : unable to prepare );
}
if (count($args)){
traceVar($args, Binding params with );
call_user_func_array(array($query, bindParam ), $args);
}
$query->execute();
$meta = $query->result_metadata();
while ($field = $meta->fetch_field()) {
$params[] = &$row[$field->name];
}
traceVar($params, Binding results with );
call_user_func_array(array($query, bind_result ), $params);
while ($query->fetch()) {
traceVar($row, After fetch );
$temp = array();
foreach($row as $key => $val) {
$temp[$key] = $val;
}
$result[] = $temp;
}
$meta->free();
$query->close();
//self::close_db_conn();
return $result;
}