/**
	 * Selects a collection of JProfesseursMatieres objects pre-filled with all related objects except Professeur.
	 *
	 * @param      Criteria  $criteria
	 * @param      PropelPDO $con
	 * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
	 * @return     array Array of JProfesseursMatieres objects.
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function doSelectJoinAllExceptProfesseur(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		$criteria = clone $criteria;

		// Set the correct dbName if it has not been overridden
		// $criteria->getDbName() will return the same object if not set to another value
		// so == check is okay and faster
		if ($criteria->getDbName() == Propel::getDefaultDB()) {
			$criteria->setDbName(self::DATABASE_NAME);
		}

		JProfesseursMatieresPeer::addSelectColumns($criteria);
		$startcol2 = JProfesseursMatieresPeer::NUM_HYDRATE_COLUMNS;

		MatierePeer::addSelectColumns($criteria);
		$startcol3 = $startcol2 + MatierePeer::NUM_HYDRATE_COLUMNS;

		$criteria->addJoin(JProfesseursMatieresPeer::ID_MATIERE, MatierePeer::MATIERE, $join_behavior);


		$stmt = BasePeer::doSelect($criteria, $con);
		$results = array();

		while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$key1 = JProfesseursMatieresPeer::getPrimaryKeyHashFromRow($row, 0);
			if (null !== ($obj1 = JProfesseursMatieresPeer::getInstanceFromPool($key1))) {
				// We no longer rehydrate the object, since this can cause data loss.
				// See http://www.propelorm.org/ticket/509
				// $obj1->hydrate($row, 0, true); // rehydrate
			} else {
				$cls = JProfesseursMatieresPeer::getOMClass(false);

				$obj1 = new $cls();
				$obj1->hydrate($row);
				JProfesseursMatieresPeer::addInstanceToPool($obj1, $key1);
			} // if obj1 already loaded

				// Add objects for joined Matiere rows

				$key2 = MatierePeer::getPrimaryKeyHashFromRow($row, $startcol2);
				if ($key2 !== null) {
					$obj2 = MatierePeer::getInstanceFromPool($key2);
					if (!$obj2) {
	
						$cls = MatierePeer::getOMClass(false);

					$obj2 = new $cls();
					$obj2->hydrate($row, $startcol2);
					MatierePeer::addInstanceToPool($obj2, $key2);
				} // if $obj2 already loaded

				// Add the $obj1 (JProfesseursMatieres) to the collection in $obj2 (Matiere)
				$obj2->addJProfesseursMatieres($obj1);

			} // if joined row is not null

			$results[] = $obj1;
		}
		$stmt->closeCursor();
		return $results;
	}
示例#2
0
	/**
	 * Find object by primary key using raw SQL to go fast.
	 * Bypass doSelect() and the object formatter by using generated code.
	 *
	 * @param     mixed $key Primary key to use for the query
	 * @param     PropelPDO $con A connection object
	 *
	 * @return    Matiere A model object, or null if the key is not found
	 */
	protected function findPkSimple($key, $con)
	{
		$sql = 'SELECT MATIERE, NOM_COMPLET, PRIORITY, MATIERE_AID, MATIERE_ATELIER, CATEGORIE_ID FROM matieres WHERE MATIERE = :p0';
		try {
			$stmt = $con->prepare($sql);
			$stmt->bindValue(':p0', $key, PDO::PARAM_STR);
			$stmt->execute();
		} catch (Exception $e) {
			Propel::log($e->getMessage(), Propel::LOG_ERR);
			throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
		}
		$obj = null;
		if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
			$obj = new Matiere();
			$obj->hydrate($row);
			MatierePeer::addInstanceToPool($obj, (string) $key);
		}
		$stmt->closeCursor();

		return $obj;
	}
示例#3
0
	/**
	 * Retrieve multiple objects by pkey.
	 *
	 * @param      array $pks List of primary keys
	 * @param      PropelPDO $con the connection to use
	 * @throws     PropelException Any exceptions caught during processing will be
	 *		 rethrown wrapped into a PropelException.
	 */
	public static function retrieveByPKs($pks, PropelPDO $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(MatierePeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria(MatierePeer::DATABASE_NAME);
			$criteria->add(MatierePeer::MATIERE, $pks, Criteria::IN);
			$objs = MatierePeer::doSelect($criteria, $con);
		}
		return $objs;
	}
示例#4
0
	/**
	 * Populates the object using an array.
	 *
	 * This is particularly useful when populating an object from one of the
	 * request arrays (e.g. $_POST).  This method goes through the column
	 * names, checking to see whether a matching key exists in populated
	 * array. If so the setByName() method is called for that column.
	 *
	 * You can specify the key type of the array by additionally passing one
	 * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
	 * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
	 * The default key type is the column's phpname (e.g. 'AuthorId')
	 *
	 * @param      array  $arr     An array to populate the object from.
	 * @param      string $keyType The type of keys the array uses.
	 * @return     void
	 */
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = MatierePeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setMatiere($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setNomComplet($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setPriority($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setMatiereAid($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setMatiereAtelier($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setCategorieId($arr[$keys[5]]);
	}
示例#5
0
文件: etape5.php 项目: rhertzog/lcs
 // On se connecte au LDAP
 $ldap->connect();
 // Si on a bien les donnees dans la session, on peut continuer
 /*
  * Recherche de tous les profs de l'établissement (pour ce RNE)
  */
 $matieres = $ldap->get_all_matieres();
 $nb_matieres = $matieres['count'];
 /*
  * Ajout des matières
  */
 for ($cpt = 0; $cpt < $matieres['count']; $cpt++) {
     $code_matiere = $matieres[$cpt]['cn'][0];
     $nom_matiere = $matieres[$cpt]['description'][0];
     // On test si on a déjà cette matière
     $nouvelle_matiere = MatierePeer::retrieveByPK($code_matiere);
     if ($nouvelle_matiere != null) {
         echo "La matière " . $nouvelle_matiere->getMatiere() . " (" . $nouvelle_matiere->getNomComplet() . ") existe d&eacute;j&agrave;<br/>";
     } else {
         $nouvelle_matiere = new Matiere();
         $nouvelle_matiere->setMatiere($code_matiere);
         $nouvelle_matiere->setNomComplet($nom_matiere);
         $nouvelle_matiere->save();
     }
     // Maintenant on associe les profs à cette matiere
     $nb_profs = $matieres[$cpt]['memberuid']['count'];
     $matiere_profs = $nouvelle_matiere->getProfesseurs();
     if ($nb_profs > 0) {
         for ($i = 0; $i < $nb_profs; $i++) {
             // On vérifie que le prof existe, quand même...
             $prof = UtilisateurProfessionnelPeer::retrieveByPK($matieres[$cpt]['memberuid'][$i]);