/**
  * Deletes all rating for a ratable object (delete cascade emulation)
  * 
  * @param  BaseObject  $object
  */
 public function preDelete(BaseObject $object)
 {
     try {
         $c = new Criteria();
         $c->add(sfRatingPeer::RATABLE_ID, $object->getReferenceKey());
         sfRatingPeer::doDelete($c);
     } catch (Exception $e) {
         throw new sfPropelActAsRatableException('Unable to delete ratable object related ratings records');
     }
 }
Пример #2
0
 public function delete($con = null)
 {
     foreach (sfMixer::getCallables('BasesfRating: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(sfRatingPeer::DATABASE_NAME);
     }
     try {
         $con->begin();
         sfRatingPeer::doDelete($this, $con);
         $this->setDeleted(true);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
     foreach (sfMixer::getCallables('BasesfRating:delete:post') as $callable) {
         call_user_func($callable, $this, $con);
     }
 }