Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/02/2017, 15:14
boistoc
 
Fecha de Ingreso: junio-2014
Mensajes: 60
Antigüedad: 9 años, 11 meses
Puntos: 0
Obtener resultados de una funcion para SQL

Buena tarde.
Estaba viendo diferentes formas de seleccionar una tabla y reducir el codigo y he encontrado el siguiente codigo:
Código PHP:
Ver original
  1. function select($table,$column = "",$where = 1,$orderby = "",$limit = ""){
  2.         if($column == "")
  3.             $column='*';
  4.         if($orderby == "")
  5.             $orderby = 'NULL';
  6.         if($limit != ""){
  7.             $limit = "LIMIT ".$limit;
  8.         }
  9.             $result = mysql_query("SELECT ".$column." FROM ".$table." WHERE ".$where." ORDER BY ".$orderby." ".$limit."");
  10.         if(!$result){
  11.             return $result;
  12.         }else{
  13.             $index = 0;
  14.             while($row = $result->fetch_assoc())
  15.         {
  16.             $data[$index] = $row;
  17.         }
  18.             return $data;
  19.         }
  20.     }
Se como convocar la función:
Código PHP:
Ver original
  1. $UsErt = select('users', 'on, username', 'id = 1');
Pero no como tomar los Array con esta función
¿Me darían una meno?
Gracias de antemano