/** * Deletes the row on the database, if it violates referential-integrity as * defined at database level it will simply return false constraints. * @return boolean */ public function delete() { $sql = "DELETE FROM {$this->_tableName}\n WHERE {$this->_idField}={$this->_id}\n LIMIT 1;"; if (!$this->_DbConnection->execute($sql)) { return false; } return true; }
public function doExecuteSql() { if ($this->isLocked()) { throw new Exception('Locked. Could not execute.'); } if ($this->checkIsExecuted()->getIsExecuted()) { throw new Exception($this->generateFilename($this->getIssueNumber(), $this->getIssueCount()) . ' has already been executed.'); } $sql = trim($this->getSql()); $res = true; if (!empty($sql)) { $this->lock(array('change' => $this->generateFilename($this->getIssueNumber(), $this->getIssueCount()), 'started' => date('Y-m-d H:i:s'))); try { $db = new DbConnection($this->settings->getDbConn($this->getDb()), true); $db->execute($sql); } catch (Exception $e) { $this->cacher->store($this->getFailName(), $e->getMessage()); $res = false; } $this->unlock(); } if ($res) { $this->setIsExecuted(true); } return $res; }