/** * Returns a new JProfesseursMatieresQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return JProfesseursMatieresQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof JProfesseursMatieresQuery) { return $criteria; } $query = new JProfesseursMatieresQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Sets a collection of Matiere objects related by a many-to-many relationship * to the current object by way of the j_professeurs_matieres cross-reference table. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * * @param PropelCollection $matieres A Propel collection. * @param PropelPDO $con Optional connection object */ public function setMatieres(PropelCollection $matieres, PropelPDO $con = null) { $jProfesseursMatieress = JProfesseursMatieresQuery::create() ->filterByMatiere($matieres) ->filterByProfesseur($this) ->find($con); $this->matieresScheduledForDeletion = $this->getJProfesseursMatieress()->diff($jProfesseursMatieress); $this->collJProfesseursMatieress = $jProfesseursMatieress; foreach ($matieres as $matiere) { // Fix issue with collection modified by reference if ($matiere->isNew()) { $this->doAddMatiere($matiere); } else { $this->addMatiere($matiere); } } $this->collMatieres = $matieres; }
/** * 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(JProfesseursMatieresPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = JProfesseursMatieresQuery::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; } }
/** * Sets a collection of UtilisateurProfessionnel objects related by a many-to-many relationship * to the current object by way of the j_professeurs_matieres cross-reference table. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * * @param PropelCollection $professeurs A Propel collection. * @param PropelPDO $con Optional connection object */ public function setProfesseurs(PropelCollection $professeurs, PropelPDO $con = null) { $jProfesseursMatieress = JProfesseursMatieresQuery::create() ->filterByUtilisateurProfessionnel($professeurs) ->filterByMatiere($this) ->find($con); $this->professeursScheduledForDeletion = $this->getJProfesseursMatieress()->diff($jProfesseursMatieress); $this->collJProfesseursMatieress = $jProfesseursMatieress; foreach ($professeurs as $professeur) { // Fix issue with collection modified by reference if ($professeur->isNew()) { $this->doAddUtilisateurProfessionnel($professeur); } else { $this->addUtilisateurProfessionnel($professeur); } } $this->collProfesseurs = $professeurs; }
$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]); // Le prof existe, on créer l'association, si elle n'existe pas encore if ($prof != null) { // L'association n'existe pas, on la créé // Pour ça, on doit déterminer l'ordre if (!$matiere_profs->contains($prof)) { $assoc = JProfesseursMatieresQuery::create()->filterByProfesseur($prof)->orderByOrdreMatieres('desc')->findOne(); $nouvel_ordre = $assoc == null ? 1 : $assoc->getOrdreMatieres() + 1; $new_assoc = new JProfesseursMatieres(); $new_assoc->setProfesseur($prof); $new_assoc->setMatiere($nouvelle_matiere); $new_assoc->setOrdreMatieres($nouvel_ordre); $new_assoc->save(); } } else { echo "Le prof associé (" . $matieres[$cpt]['memberuid'][$i] . ") n'existe pas dans la base !<br/>"; } } } } // fin parcours des matières /*