/**
	 * Returns a new CategorieMatiereQuery object.
	 *
	 * @param     string $modelAlias The alias of a model in the query
	 * @param     Criteria $criteria Optional Criteria to build the query from
	 *
	 * @return    CategorieMatiereQuery
	 */
	public static function create($modelAlias = null, $criteria = null)
	{
		if ($criteria instanceof CategorieMatiereQuery) {
			return $criteria;
		}
		$query = new CategorieMatiereQuery();
		if (null !== $modelAlias) {
			$query->setModelAlias($modelAlias);
		}
		if ($criteria instanceof Criteria) {
			$query->mergeWith($criteria);
		}
		return $query;
	}
Example #2
0
	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());
		}
	}
Example #3
0
	/**
	 * 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;
	}
Example #4
0
	/**
	 * 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);
		}
	}
Example #5
0
	/**
	 * 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;
		}
	}