Example #1
0
 public function __construct()
 {
     Sfphp_Sesion::get();
     $peticion = Sfphp_Peticion::get();
     $clase = NULL;
     if (!is_null($peticion['_modulo'])) {
         $clase = ucwords($peticion['_modulo']) . "_";
     }
     $clase .= "Controladores_" . ucwords($peticion['_control']);
     try {
         $objSeguridad = new Seguridad();
         if ($objSeguridad->validarAcceso(ucwords($peticion['_control']))) {
             $objClase = new $clase();
             if (is_callable(array($objClase, $peticion['_accion']))) {
                 call_user_func(array($objClase, $peticion['_accion']));
             } else {
                 throw new Sfphp_Error("La accion {$peticion['_accion']} no esta definida en {$clase}", 1);
             }
         } else {
             throw new Sfphp_Error("No tienes privilegios para acceder a {$clase}::{$peticion['_accion']}", 1);
         }
     } catch (Sfphp_Error $e) {
         Sfphp_Logs::procesa($e);
     }
 }
Example #2
0
 public function insert($consulta, $valores = array())
 {
     $resultado = false;
     if ($statement = self::$default->prepare($consulta)) {
         if (preg_match_all("/(:\\w+)/", $consulta, $campo, PREG_PATTERN_ORDER)) {
             $campo = array_pop($campo);
             foreach ($campo as $parametro) {
                 $statement->bindValue($parametro, $valores[substr($parametro, 1)]);
             }
         }
         try {
             if (!$statement->execute()) {
                 throw new PDOException("[SQLSTATE] " . $statement->errorInfo()[2], $statement->errorInfo()[1]);
             }
             $resultado = self::$default->lastInsertId();
         } catch (PDOException $e) {
             Sfphp_Logs::procesa($e);
             return false;
         }
         return $resultado;
     }
 }