Created
September 30, 2012 07:23
-
-
Save dvidsilva/3806154 to your computer and use it in GitHub Desktop.
Returns the result of a query as an array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//receives a query and returns an array in the following format | |
// array['row-number']['field_name'] = 'value' | |
function q2ar($query){ | |
$query = $this->mysql($query); | |
$n=0; | |
$data = ''; | |
if(is_resource($query)){ | |
while($row = mysql_fetch_row($query) ){ | |
$i=0; | |
while ($i < mysql_num_fields($query)){ | |
$meta = mysql_fetch_field($query, $i); | |
$data[$n][$meta->name] = $row[$i]; | |
$i++; | |
} | |
$n++; | |
} | |
return ($data); | |
}else{ | |
return (false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment