Created
February 22, 2014 14:40
-
-
Save reactormade/9155838 to your computer and use it in GitHub Desktop.
Simple MySQL query result to array of objects conversion
This file contains hidden or 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
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