예제 #1
0
	/**
	 * Returns a new JGroupesMatieresQuery object.
	 *
	 * @param     string $modelAlias The alias of a model in the query
	 * @param     Criteria $criteria Optional Criteria to build the query from
	 *
	 * @return    JGroupesMatieresQuery
	 */
	public static function create($modelAlias = null, $criteria = null)
	{
		if ($criteria instanceof JGroupesMatieresQuery) {
			return $criteria;
		}
		$query = new JGroupesMatieresQuery();
		if (null !== $modelAlias) {
			$query->setModelAlias($modelAlias);
		}
		if ($criteria instanceof Criteria) {
			$query->mergeWith($criteria);
		}
		return $query;
	}
예제 #2
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(JGroupesMatieresPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}

		$con->beginTransaction();
		try {
			$deleteQuery = JGroupesMatieresQuery::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;
		}
	}
예제 #3
0
파일: BaseGroupe.php 프로젝트: rhertzog/lcs
	/**
	 * Sets a collection of Matiere objects related by a many-to-many relationship
	 * to the current object by way of the j_groupes_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)
	{
		$jGroupesMatieress = JGroupesMatieresQuery::create()
			->filterByMatiere($matieres)
			->filterByGroupe($this)
			->find($con);

		$this->matieresScheduledForDeletion = $this->getJGroupesMatieress()->diff($jGroupesMatieress);
		$this->collJGroupesMatieress = $jGroupesMatieress;

		foreach ($matieres as $matiere) {
			// Fix issue with collection modified by reference
			if ($matiere->isNew()) {
				$this->doAddMatiere($matiere);
			} else {
				$this->addMatiere($matiere);
			}
		}

		$this->collMatieres = $matieres;
	}