Example #1
0
 private function recuperarBusqueda($busca)
 {
     try {
         $comando = "SELECT " . self::ID_USUARIO . "," . self::NOMBRE . "," . self::IMGPERFIL . " FROM " . self::NOMBRE_TABLA . " WHERE " . self::NOMBRE . " LIKE '%" . $busca . "%'";
         // Preparar sentencia
         $sentencia = ConexionBD::obtenerInstancia()->obtenerBD()->prepare($comando);
         // Ejecutar sentencia preparada
         if ($sentencia->execute()) {
             $usuarios = $sentencia->fetchAll(PDO::FETCH_ASSOC);
             $rutas = ruta::obtenerRutas($busca);
             http_response_code(200);
             return ["estado" => self::ESTADO_EXITO, "mensaje" => "Consulta de usuario con todo exitosa", "todo" => ["usuario" => $usuarios, "rutas" => $rutas]];
         } else {
             throw new ExcepcionApi(self::ESTADO_ERROR, "Se ha producido un error");
         }
     } catch (PDOException $e) {
         throw new ExcepcionApi(self::ESTADO_ERROR_BD, $e->getMessage());
     }
 }