/** * 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 (AbsenceEleveSaisieQuery::isSoftDeleteEnabled() && $this->localSoftDelete) { return $this->softDelete($con); } else { return $this->hasWhereClause() ? $this->forceDelete($con) : $this->forceDeleteAll($con); } return $this->preDelete($con); }
/** * Check the soft_delete behavior for this model * @return boolean true if the soft_delete behavior is enabled */ public static function isSoftDeleteEnabled() { return AbsenceEleveSaisieQuery::isSoftDeleteEnabled(); }
/** * 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(AbsenceEleveSaisiePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = AbsenceEleveSaisieQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); // soft_delete behavior if (!empty($ret) && AbsenceEleveSaisieQuery::isSoftDeleteEnabled()) { $this->keepUpdateDateUnchanged(); $this->setDeletedAt(time()); $this->save($con); $this->postDelete($con); $con->commit(); AbsenceEleveSaisiePeer::removeInstanceFromPool($this); return; } if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); // versionable behavior // emulate delete cascade AbsenceEleveSaisieVersionQuery::create() ->filterByAbsenceEleveSaisie($this) ->delete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }