/** * Deletes all comments for a commentable object (on delete cascade emulation) * * @param BaseObject $object */ public function preDelete(BaseObject $object) { try { $c = new Criteria(); $c->add(sfCommentPeer::COMMENTABLE_ID, $object->getPrimaryKey()); sfCommentPeer::doDelete($c); } catch (Exception $e) { throw new Exception('Unable to delete comments related to commentable object'); } }
/** * Removes one comment from the object. * * @param BaseObject $object */ public function removeComment(BaseObject $object, $comment_id) { $c = new Criteria(); $c->add(sfCommentPeer::COMMENTABLE_ID, $object->getPrimaryKey()); $c->add(sfCommentPeer::COMMENTABLE_MODEL, get_class($object)); $c->add(sfCommentPeer::ID, $comment_id); return sfCommentPeer::doDelete($c); }
public function delete($con = null) { foreach (sfMixer::getCallables('BasesfComment:delete:pre') as $callable) { $ret = call_user_func($callable, $this, $con); if ($ret) { return; } } if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(sfCommentPeer::DATABASE_NAME); } try { $con->begin(); sfCommentPeer::doDelete($this, $con); $this->setDeleted(true); $con->commit(); } catch (PropelException $e) { $con->rollback(); throw $e; } foreach (sfMixer::getCallables('BasesfComment:delete:post') as $callable) { call_user_func($callable, $this, $con); } }