Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save reactormade/9155838 to your computer and use it in GitHub Desktop.
Save reactormade/9155838 to your computer and use it in GitHub Desktop.
Simple MySQL query result to array of objects conversion
if(!function_exists('converte_query_result_em_array_of_objects')):
/**
* CONVERTE ARRAY DE QUERY RESULT
* EM ARRAY DE OBJETOS PARA ACESSO DIRETO
**/
function converte_query_result_em_array_of_objects($array){
if(is_array($array) && is_resource($array)):
$output = array();
while($row = mysql_fetch_assoc($array)): $output[] = (object)$row; endwhile;
return $output;
else:
return $array;
endif;
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment