public function executeDelete(sfWebRequest $request) { $type = $request->getParameter('type'); $id = $request->getParameter('id'); $c = new Criteria(); try { if ($type == "brand") { BrandPeer::doDelete($c->add(BrandPeer::ID, $id)); } if ($type == "series") { SeriesPeer::doDelete($c->add(SeriesPeer::ID, $id)); } if ($type == "model") { ModelPeer::doDelete($c->add(ModelPeer::ID, $id)); } if ($type == "config") { ConfigPeer::doDelete($c->add(ConfigPeer::ID, $id)); } $this->res = "OK"; } catch (Exception $exc) { $this->res = $exc->getMessage(); } }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(SeriesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $ret = $this->preDelete($con); // symfony_behaviors behavior foreach (sfMixer::getCallables('BaseSeries:delete:pre') as $callable) { if (call_user_func($callable, $this, $con)) { $con->commit(); return; } } if ($ret) { SeriesPeer::doDelete($this, $con); $this->postDelete($con); // symfony_behaviors behavior foreach (sfMixer::getCallables('BaseSeries:delete:post') as $callable) { call_user_func($callable, $this, $con); } $this->setDeleted(true); $con->commit(); } else { $con->commit(); } } catch (PropelException $e) { $con->rollBack(); throw $e; } }