Exemplo n.º 1
0
	/**
	 * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
	 * feature (like MySQL or SQLite).
	 *
	 * This method is not very speedy because it must perform a query first to get
	 * the implicated records and then perform the deletes by calling those Peer classes.
	 *
	 * This method should be used within a transaction if possible.
	 *
	 * @param      Criteria $criteria
	 * @param      PropelPDO $con
	 * @return     int The number of affected rows (if supported by underlying database driver).
	 */
	protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
	{
		// initialize var to track total num of affected rows
		$affectedRows = 0;

		// first find the objects that are implicated by the $criteria
		$objects = ElevePeer::doSelect($criteria, $con);
		foreach ($objects as $obj) {


			// delete related JEleveClasse objects
			$criteria = new Criteria(JEleveClassePeer::DATABASE_NAME);
			
			$criteria->add(JEleveClassePeer::LOGIN, $obj->getLogin());
			$affectedRows += JEleveClassePeer::doDelete($criteria, $con);

			// delete related JEleveCpe objects
			$criteria = new Criteria(JEleveCpePeer::DATABASE_NAME);
			
			$criteria->add(JEleveCpePeer::E_LOGIN, $obj->getLogin());
			$affectedRows += JEleveCpePeer::doDelete($criteria, $con);

			// delete related JEleveGroupe objects
			$criteria = new Criteria(JEleveGroupePeer::DATABASE_NAME);
			
			$criteria->add(JEleveGroupePeer::LOGIN, $obj->getLogin());
			$affectedRows += JEleveGroupePeer::doDelete($criteria, $con);

			// delete related JEleveProfesseurPrincipal objects
			$criteria = new Criteria(JEleveProfesseurPrincipalPeer::DATABASE_NAME);
			
			$criteria->add(JEleveProfesseurPrincipalPeer::LOGIN, $obj->getLogin());
			$affectedRows += JEleveProfesseurPrincipalPeer::doDelete($criteria, $con);

			// delete related EleveRegimeDoublant objects
			$criteria = new Criteria(EleveRegimeDoublantPeer::DATABASE_NAME);
			
			$criteria->add(EleveRegimeDoublantPeer::LOGIN, $obj->getLogin());
			$affectedRows += EleveRegimeDoublantPeer::doDelete($criteria, $con);

			// delete related ResponsableInformation objects
			$criteria = new Criteria(ResponsableInformationPeer::DATABASE_NAME);
			
			$criteria->add(ResponsableInformationPeer::ELE_ID, $obj->getEleId());
			$affectedRows += ResponsableInformationPeer::doDelete($criteria, $con);

			// delete related JEleveAncienEtablissement objects
			$criteria = new Criteria(JEleveAncienEtablissementPeer::DATABASE_NAME);
			
			$criteria->add(JEleveAncienEtablissementPeer::ID_ELEVE, $obj->getId());
			$affectedRows += JEleveAncienEtablissementPeer::doDelete($criteria, $con);

			// delete related JAidEleves objects
			$criteria = new Criteria(JAidElevesPeer::DATABASE_NAME);
			
			$criteria->add(JAidElevesPeer::LOGIN, $obj->getLogin());
			$affectedRows += JAidElevesPeer::doDelete($criteria, $con);

			// delete related AbsenceEleveSaisie objects
			$criteria = new Criteria(AbsenceEleveSaisiePeer::DATABASE_NAME);
			
			$criteria->add(AbsenceEleveSaisiePeer::ELEVE_ID, $obj->getId());
			$affectedRows += AbsenceEleveSaisiePeer::doDelete($criteria, $con);

			// delete related AbsenceAgregationDecompte objects
			$criteria = new Criteria(AbsenceAgregationDecomptePeer::DATABASE_NAME);
			
			$criteria->add(AbsenceAgregationDecomptePeer::ELEVE_ID, $obj->getId());
			$affectedRows += AbsenceAgregationDecomptePeer::doDelete($criteria, $con);

			// delete related CreditEcts objects
			$criteria = new Criteria(CreditEctsPeer::DATABASE_NAME);
			
			$criteria->add(CreditEctsPeer::ID_ELEVE, $obj->getId());
			$affectedRows += CreditEctsPeer::doDelete($criteria, $con);

			// delete related CreditEctsGlobal objects
			$criteria = new Criteria(CreditEctsGlobalPeer::DATABASE_NAME);
			
			$criteria->add(CreditEctsGlobalPeer::ID_ELEVE, $obj->getId());
			$affectedRows += CreditEctsGlobalPeer::doDelete($criteria, $con);

			// delete related ArchiveEcts objects
			$criteria = new Criteria(ArchiveEctsPeer::DATABASE_NAME);
			
			$criteria->add(ArchiveEctsPeer::INE, $obj->getNoGep());
			$affectedRows += ArchiveEctsPeer::doDelete($criteria, $con);
		}
		return $affectedRows;
	}
Exemplo n.º 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    CreditEctsGlobal A model object, or null if the key is not found
	 */
	protected function findPkSimple($key, $con)
	{
		$sql = 'SELECT ID, ID_ELEVE, MENTION FROM ects_global_credits WHERE ID = :p0 AND ID_ELEVE = :p1';
		try {
			$stmt = $con->prepare($sql);
			$stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
			$stmt->bindValue(':p1', $key[1], PDO::PARAM_INT);
			$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 CreditEctsGlobal();
			$obj->hydrate($row);
			CreditEctsGlobalPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1])));
		}
		$stmt->closeCursor();

		return $obj;
	}
Exemplo n.º 3
0
	/**
	 * Retrieve object using using composite pkey values.
	 * @param      int $id
	 * @param      int $id_eleve
	 * @param      PropelPDO $con
	 * @return     CreditEctsGlobal
	 */
	public static function retrieveByPK($id, $id_eleve, PropelPDO $con = null) {
		$_instancePoolKey = serialize(array((string) $id, (string) $id_eleve));
 		if (null !== ($obj = CreditEctsGlobalPeer::getInstanceFromPool($_instancePoolKey))) {
 			return $obj;
		}

		if ($con === null) {
			$con = Propel::getConnection(CreditEctsGlobalPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}
		$criteria = new Criteria(CreditEctsGlobalPeer::DATABASE_NAME);
		$criteria->add(CreditEctsGlobalPeer::ID, $id);
		$criteria->add(CreditEctsGlobalPeer::ID_ELEVE, $id_eleve);
		$v = CreditEctsGlobalPeer::doSelect($criteria, $con);

		return !empty($v) ? $v[0] : null;
	}
Exemplo n.º 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 = CreditEctsGlobalPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setIdEleve($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setMention($arr[$keys[2]]);
	}