/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @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(CotisationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = CotisationQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // soft_delete behavior if (!empty($ret) && CotisationQuery::isSoftDeleteEnabled()) { $this->keepUpdateDateUnchanged(); $this->setDeletedAt(time()); $this->save($con); $this->postDelete($con); $con->commit(); CotisationPeer::removeInstanceFromPool($this); return; } if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * Check the soft_delete behavior for this model * @return boolean true if the soft_delete behavior is enabled */ public static function isSoftDeleteEnabled() { return CotisationQuery::isSoftDeleteEnabled(); }
/** * Code to execute before every DELETE statement * * @param PropelPDO $con The connection object used by the query */ protected function basePreDelete(PropelPDO $con) { // soft_delete behavior if (CotisationQuery::isSoftDeleteEnabled() && $this->localSoftDelete) { return $this->softDelete($con); } else { return $this->hasWhereClause() ? $this->forceDelete($con) : $this->forceDeleteAll($con); } return $this->preDelete($con); }