Esempio 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;
	}