public function update(Vo $objetoVo) { $valores = $objetoVo->getAll(); $parametros = array(); $where = NULL; foreach ($valores as $atributo => $valor) { if ($atributo == $this->pk) { $where = $atributo . ' = :' . $atributo; continue; } $parametros[] = $atributo . ' = :' . $atributo; } if ($where === NULL) { throw new Exception('PK não encontrada no Vo'); } $sql = 'UPDATE ' . $this->tabela . ' SET ' . join(', ', $parametros) . ' WHERE ' . $where; $con = Conexao::getInstance(); $stmt = $con->prepare($sql); return $stmt->execute($valores); }
public function create(Vo $vo) { $vo->setSenha(md5($vo->getSenha())); return parent::create($vo); }