sql >> Base de Datos >  >> RDS >> Mysql

función auxiliar fetchAll usando PDO

editar: como indicó el Coronel, aparentemente esto (¿ya no?) funciona con LIMIT cláusulas.

Si está utilizando consultas simples / no está tan molesto con el tipo:

function fetchAll(){
   $args = func_get_args();
   $query = array_shift($args);//'SELECT * FROM users WHERE status=? LIMIT ?,?'
   //you'll need a reference to your PDO instance $pdo somewhere....
   $stmt = $pdo->prepare($query);
   $stmt->execute($args);
   return $stmt->fetchAll();
}