/** * Returns a new JCategoriesMatieresClassesQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return JCategoriesMatieresClassesQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof JCategoriesMatieresClassesQuery) { return $criteria; } $query = new JCategoriesMatieresClassesQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Sets a collection 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. * 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 $categorieMatieres A Propel collection. * @param PropelPDO $con Optional connection object */ public function setCategorieMatieres(PropelCollection $categorieMatieres, PropelPDO $con = null) { $jCategoriesMatieresClassess = JCategoriesMatieresClassesQuery::create() ->filterByCategorieMatiere($categorieMatieres) ->filterByClasse($this) ->find($con); $this->categorieMatieresScheduledForDeletion = $this->getJCategoriesMatieresClassess()->diff($jCategoriesMatieresClassess); $this->collJCategoriesMatieresClassess = $jCategoriesMatieresClassess; foreach ($categorieMatieres as $categorieMatiere) { // Fix issue with collection modified by reference if ($categorieMatiere->isNew()) { $this->doAddCategorieMatiere($categorieMatiere); } else { $this->addCategorieMatiere($categorieMatiere); } } $this->collCategorieMatieres = $categorieMatieres; }
/** * 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(JCategoriesMatieresClassesPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = JCategoriesMatieresClassesQuery::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; } }