public function Load($where = null, $bindarr = false, $lock = false)
 {
     if (is_numeric($where)) {
         $where = $this->_prefix . "id = " . $where;
     }
     $ret = parent::Load($where, $bindarr, $lock);
     if ($ret && $this->has_meta()) {
         $this->load_meta($this);
     }
     return $ret;
 }
Exemplo n.º 2
0
 public function editarRegistro()
 {
     $this->usarScaffold();
     //Conectarse a la base de datos
     if ($this->db == "") {
         $this->db = "default";
     }
     $conexion = $this->nucleo->getConexion($this->db);
     $conexion->Execute("SET NAMES utf8");
     //Primarias en $primarias
     //Demas campos en $campos
     $campos = $this->getCampos();
     $registro = new ADOdb_Active_Record($this->modelo);
     $where = "";
     foreach ($campos as $c) {
         if ($c["primaria"] == 1) {
             if ($where != "") {
                 $where .= " AND ";
             }
             $where .= $c["nombre"] . "=" . $this->par['pri_' . $c["nombre"]];
         }
     }
     $registro->Load($where);
     foreach ($campos as $c) {
         if ($c["auto"] == 1) {
         } elseif ($c["nombre"] == "password" || $c["nombre"] == "contrasena") {
             if ($this->par[$c["nombre"]] != "") {
                 $registro->{$c}["nombre"] = md5($this->par[$c["nombre"]]);
             }
         } elseif ($c["nombre"] == "texto") {
             $registro->{$c}["nombre"] = stripslashes($this->par[$c["nombre"]]);
         } else {
             $registro->{$c}["nombre"] = $this->par[$c["nombre"]];
         }
     }
     if ($registro->Save()) {
         $this->set("editado", "1");
         $this->listado();
         $this->set("vista", "listado");
     } else {
         $this->set("editado", "0");
         $this->agregar();
         $this->set("vista", "agregar");
     }
 }