Posted By

gdonald on 09/26/06


Tagged

fetch mysql php array mysqli


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


php mysql/mysqli fetch array


 / Published in: PHP
 

  1. function sqlFetchArray( $query, $type='MYSQL_ASSOC' )
  2. {
  3. if( in_array( 'mysql', $GLOBALS[ 'loaded_extensions' ] ) )
  4. {
  5. switch( $type )
  6. {
  7. case 'MYSQL_NUM':
  8. return @mysql_fetch_array( $query, MYSQL_NUM );
  9. break;
  10. case 'MYSQL_ASSOC':
  11. return @mysql_fetch_array( $query, MYSQL_ASSOC );
  12. break;
  13. case 'MYSQL_BOTH':
  14. return @mysql_fetch_array( $query, MYSQL_BOTH );
  15. break;
  16. }
  17. }
  18. elseif( in_array( 'mysqli', $GLOBALS[ 'loaded_extensions' ] ) )
  19. {
  20. switch( $type )
  21. {
  22. case 'MYSQL_NUM':
  23. return @mysqli_fetch_array( $query, MYSQLI_NUM );
  24. break;
  25. case 'MYSQL_ASSOC':
  26. return @mysqli_fetch_array( $query, MYSQLI_ASSOC );
  27. break;
  28. case 'MYSQL_BOTH':
  29. return @mysqli_fetch_array( $query, MYSQLI_BOTH );
  30. break;
  31. }
  32. }
  33. }

Report this snippet  

You need to login to post a comment.