Beispiel #1
0
	/**
	 * Returns a new MatiereQuery object.
	 *
	 * @param     string $modelAlias The alias of a model in the query
	 * @param     Criteria $criteria Optional Criteria to build the query from
	 *
	 * @return    MatiereQuery
	 */
	public static function create($modelAlias = null, $criteria = null)
	{
		if ($criteria instanceof MatiereQuery) {
			return $criteria;
		}
		$query = new MatiereQuery();
		if (null !== $modelAlias) {
			$query->setModelAlias($modelAlias);
		}
		if ($criteria instanceof Criteria) {
			$query->mergeWith($criteria);
		}
		return $query;
	}
Beispiel #2
0
	/**
	 * Get the associated Matiere object
	 *
	 * @param      PropelPDO Optional Connection object.
	 * @return     Matiere The associated Matiere object.
	 * @throws     PropelException
	 */
	public function getMatiere(PropelPDO $con = null)
	{
		if ($this->aMatiere === null && (($this->id_matiere !== "" && $this->id_matiere !== null))) {
			$this->aMatiere = MatiereQuery::create()->findPk($this->id_matiere, $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->aMatiere->addJGroupesMatieress($this);
			 */
		}
		return $this->aMatiere;
	}
Beispiel #3
0
 /**
  * Renvoie la liste des matières avec le nom long
  *
  * @return array Tableau des matières nom court - nom long - - - - - -
  */
 public function listeMatieresAvecNomlong()
 {
     $matieres = MatiereQuery::create()->orderByMatiere()->find();
     $retour = $this->_format == 'xml' ? '<?xml version=\'1.0\' encoding=\'UTF-8\'?><matieres>' : array();
     foreach ($matieres as $matiere) {
         if ($this->_format == 'xml') {
             $retour .= '
       <matiere>
         <nom>' . htmlspecialchars($matiere->getMatiere()) . '</nom>
         <nomcomplet>' . htmlspecialchars($matiere->getNomComplet()) . '</nomcomplet>
       </matiere>
                 ';
         } else {
             $retour[] = array($matiere->getMatiere(), $matiere->getNomComplet(), '', '', '', '', array());
         }
     }
     if ($this->_format == 'xml') {
         $retour .= '</matieres>';
     }
     return $retour;
 }
	/**
	 * Gets the number of Matiere objects related by a many-to-many relationship
	 * to the current object by way of the j_professeurs_matieres 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 Matiere objects
	 */
	public function countMatieres($criteria = null, $distinct = false, PropelPDO $con = null)
	{
		if(null === $this->collMatieres || null !== $criteria) {
			if ($this->isNew() && null === $this->collMatieres) {
				return 0;
			} else {
				$query = MatiereQuery::create(null, $criteria);
				if($distinct) {
					$query->distinct();
				}
				return $query
					->filterByProfesseur($this)
					->count($con);
			}
		} else {
			return count($this->collMatieres);
		}
	}
Beispiel #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(MatierePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}

		$con->beginTransaction();
		try {
			$deleteQuery = MatiereQuery::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;
		}
	}