public function getCategorieMatiere($id_classe) { $criteria = new Criteria(); $criteria->add(JGroupesClassesPeer::ID_CLASSE,$id_classe); $g = $this->getJGroupesClassess($criteria); if ($g->isEmpty()) { return false; } else { $jGroupeClasse = $g->getFirst(); return CategorieMatiereQuery::create()->findOneById($jGroupeClasse->getCategorieId()); } }
/** * Gets the number of CategorieMatiere objects related by a many-to-many relationship * to the current object by way of the j_matieres_categories_classes 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 CategorieMatiere objects */ public function countCategorieMatieres($criteria = null, $distinct = false, PropelPDO $con = null) { if(null === $this->collCategorieMatieres || null !== $criteria) { if ($this->isNew() && null === $this->collCategorieMatieres) { return 0; } else { $query = CategorieMatiereQuery::create(null, $criteria); if($distinct) { $query->distinct(); } return $query ->filterByClasse($this) ->count($con); } } else { return count($this->collCategorieMatieres); } }
/** * Get the associated CategorieMatiere object * * @param PropelPDO Optional Connection object. * @return CategorieMatiere The associated CategorieMatiere object. * @throws PropelException */ public function getCategorieMatiere(PropelPDO $con = null) { if ($this->aCategorieMatiere === null && ($this->categorie_id !== null)) { $this->aCategorieMatiere = CategorieMatiereQuery::create()->findPk($this->categorie_id, $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->aCategorieMatiere->addMatieres($this); */ } return $this->aCategorieMatiere; }
/** * 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(CategorieMatierePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = CategorieMatiereQuery::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; } }