public function execute() { $stmt = $this->conn->prepare($this->sql); try { if ($stmt->execute()) { if (is_null($this->keyValues)) { $this->keyValues = $this->conn->lastInsertId(); if (isset($this->_camposComplementares)) { foreach ($this->_camposComplementares as &$cc) { $cc['codregistro'] = $this->keyValues; } } } $config = Registry::get('config'); $configurable = false; if (array_key_exists('general.dynamicForms', $config)) { $configurable = (bool) $config['general.dynamicForms']; } if ($configurable) { $configuration = new FormConfiguration(); if (in_array($this->type, array('insert', 'update'))) { if (isset($this->_camposComplementares)) { $repo = $configuration->getRepoCampoFormularioValor(); $repo->salvarValores($this->_camposComplementares); } } elseif ($this->type === 'delete') { if (isset($this->_codigosExcluir)) { $configuration = new FormConfiguration(); $configuration->delete($this->table, $this->_codigosExcluir); } } } return $this->setCached(false)->getReference($this->keyValues); } else { return false; } } catch (\PDOException $e) { throw new Exception($e->getMessage()); } }