/** * @param SavableModelInterface $model * @throws DirtyModelException * @throws NothingDeletedException */ public function purge(SavableModelInterface $model) { if ($model->isDirty()) { throw new DirtyModelException('Dirty model cannot be purged.'); } }
/** * @param SavableModelInterface $model * @throws DirtyModelException * @throws NothingDeletedException */ public function purge(SavableModelInterface $model) { if ($model->isDirty()) { throw new DirtyModelException('Dirty model cannot be purged.'); } $bindData = array('whereId' => $model->getId()); $query = $this->pdo->prepare('delete from ' . $this->table . ' where id = :whereId'); $query->execute($bindData); $affectedRowCount = $query->rowCount(); $query->closeCursor(); if (!$affectedRowCount) { throw new NothingDeletedException(sprintf('Noting deleted from %s with %s id', $this->table, $model->getId())); } }