/** * Get the associated AncienEtablissement object * * @param PropelPDO Optional Connection object. * @return AncienEtablissement The associated AncienEtablissement object. * @throws PropelException */ public function getAncienEtablissement(PropelPDO $con = null) { if ($this->aAncienEtablissement === null && (($this->id_etablissement !== "" && $this->id_etablissement !== null))) { $this->aAncienEtablissement = AncienEtablissementQuery::create()->findPk($this->id_etablissement, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aAncienEtablissement->addJEleveAncienEtablissements($this); */ } return $this->aAncienEtablissement; }
/** * Gets the number of AncienEtablissement objects related by a many-to-many relationship * to the current object by way of the j_eleves_etablissements cross-reference table. * * @param Criteria $criteria Optional query object to filter the query * @param boolean $distinct Set to true to force count distinct * @param PropelPDO $con Optional connection object * * @return int the number of related AncienEtablissement objects */ public function countAncienEtablissements($criteria = null, $distinct = false, PropelPDO $con = null) { if(null === $this->collAncienEtablissements || null !== $criteria) { if ($this->isNew() && null === $this->collAncienEtablissements) { return 0; } else { $query = AncienEtablissementQuery::create(null, $criteria); if($distinct) { $query->distinct(); } return $query ->filterByEleve($this) ->count($con); } } else { return count($this->collAncienEtablissements); } }
/** * 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(AncienEtablissementPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = AncienEtablissementQuery::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; } }