/** * 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(JGroupesProfesseursPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = JGroupesProfesseursQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * Sets a collection of Groupe objects related by a many-to-many relationship * to the current object by way of the j_groupes_professeurs cross-reference table. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * * @param PropelCollection $groupes A Propel collection. * @param PropelPDO $con Optional connection object */ public function setGroupes(PropelCollection $groupes, PropelPDO $con = null) { $jGroupesProfesseurss = JGroupesProfesseursQuery::create() ->filterByGroupe($groupes) ->filterByUtilisateurProfessionnel($this) ->find($con); $this->groupesScheduledForDeletion = $this->getJGroupesProfesseurss()->diff($jGroupesProfesseurss); $this->collJGroupesProfesseurss = $jGroupesProfesseurss; foreach ($groupes as $groupe) { // Fix issue with collection modified by reference if ($groupe->isNew()) { $this->doAddGroupe($groupe); } else { $this->addGroupe($groupe); } } $this->collGroupes = $groupes; }