public function testApplyLimitDuplicateColumnName()
 {
     Propel::setDb('oracle', new DBOracle());
     $c = new Criteria();
     $c->setDbName('oracle');
     BookPeer::addSelectColumns($c);
     AuthorPeer::addSelectColumns($c);
     $c->setLimit(1);
     $params = array();
     $sql = BasePeer::createSelectSql($c, $params);
     $this->assertEquals('SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.ID AS book_ID, book.TITLE AS book_TITLE, book.ISBN AS book_ISBN, book.PRICE AS book_PRICE, book.PUBLISHER_ID AS book_PUBLISHER_ID, book.AUTHOR_ID AS book_AUTHOR_ID, author.ID AS author_ID, author.FIRST_NAME AS author_FIRST_NAME, author.LAST_NAME AS author_LAST_NAME, author.EMAIL AS author_EMAIL, author.AGE AS author_AGESELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID, author.ID, author.FIRST_NAME, author.LAST_NAME, author.EMAIL, author.AGE FROM book, author) A ) B WHERE  B.PROPEL_ROWNUM <= 1', $sql, 'applyLimit() creates a subselect with aliased column names when a duplicate column name is found');
 }
Example #2
0
 public function testApplyLimitDuplicateColumnNameWithColumn()
 {
     Propel::setDb('oracle', new DBOracle());
     $c = new Criteria();
     $c->setDbName('oracle');
     BookPeer::addSelectColumns($c);
     AuthorPeer::addSelectColumns($c);
     $c->addAsColumn('BOOK_PRICE', BookPeer::PRICE);
     $c->setLimit(1);
     $params = array();
     $asColumns = $c->getAsColumns();
     $sql = BasePeer::createSelectSql($c, $params);
     $this->assertEquals('SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.ID AS ORA_COL_ALIAS_0, book.TITLE AS ORA_COL_ALIAS_1, book.ISBN AS ORA_COL_ALIAS_2, book.PRICE AS ORA_COL_ALIAS_3, book.PUBLISHER_ID AS ORA_COL_ALIAS_4, book.AUTHOR_ID AS ORA_COL_ALIAS_5, author.ID AS ORA_COL_ALIAS_6, author.FIRST_NAME AS ORA_COL_ALIAS_7, author.LAST_NAME AS ORA_COL_ALIAS_8, author.EMAIL AS ORA_COL_ALIAS_9, author.AGE AS ORA_COL_ALIAS_10, book.PRICE AS BOOK_PRICE FROM book, author) A ) B WHERE  B.PROPEL_ROWNUM <= 1', $sql, 'applyLimit() creates a subselect with aliased column names when a duplicate column name is found');
     $this->assertEquals($asColumns, $c->getAsColumns(), 'createSelectSql supplementary add alias column');
 }
 public function testApplyLimitDuplicateColumnNameWithColumn()
 {
     Propel::setDb('oracle', new DBOracle());
     $c = new Criteria();
     $c->setDbName('oracle');
     BookPeer::addSelectColumns($c);
     AuthorPeer::addSelectColumns($c);
     $c->addAsColumn('BOOK_PRICE', BookPeer::PRICE);
     $c->setLimit(1);
     $params = array();
     $asColumns = $c->getAsColumns();
     $sql = BasePeer::createSelectSql($c, $params);
     $this->assertEquals('SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.id AS ORA_COL_ALIAS_0, book.title AS ORA_COL_ALIAS_1, book.isbn AS ORA_COL_ALIAS_2, book.price AS ORA_COL_ALIAS_3, book.publisher_id AS ORA_COL_ALIAS_4, book.author_id AS ORA_COL_ALIAS_5, author.id AS ORA_COL_ALIAS_6, author.first_name AS ORA_COL_ALIAS_7, author.last_name AS ORA_COL_ALIAS_8, author.email AS ORA_COL_ALIAS_9, author.age AS ORA_COL_ALIAS_10, book.price AS BOOK_PRICE FROM book, author) A ) B WHERE  B.PROPEL_ROWNUM <= 1', $sql, 'applyLimit() creates a subselect with aliased column names when a duplicate column name is found');
     $this->assertEquals($asColumns, $c->getAsColumns(), 'createSelectSql supplementary add alias column');
 }
	/**
	 * Method to soft delete all rows from the a_traitements table.
	 *
	 * @param			 PropelPDO $con the connection to use
	 * @return		 int The number of affected rows (if supported by underlying database driver).
	 * @throws		 PropelException Any exceptions caught during processing will be
	 *							rethrown wrapped into a PropelException.
	 */
	public static function doSoftDeleteAll(PropelPDO $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(AbsenceEleveTraitementPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		$selectCriteria = new Criteria();
		$selectCriteria->add(AbsenceEleveTraitementPeer::DELETED_AT, null, Criteria::ISNULL);
		$selectCriteria->setDbName(AbsenceEleveTraitementPeer::DATABASE_NAME);
		$modifyCriteria = new Criteria();
		$modifyCriteria->add(AbsenceEleveTraitementPeer::DELETED_AT, time());
		return BasePeer::doUpdate($selectCriteria, $modifyCriteria, $con);
	}
Example #5
0
 /**
  * Method perform a DELETE on the database, given a Role or Criteria object OR a primary key value.
  *
  * @param      mixed $values Criteria or Role object or primary key or array of primary keys
  *              which is used to create the DELETE statement
  * @param      PropelPDO $con the connection to use
  * @return     int 	The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
  *				if supported by native driver or if emulated using Propel.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(RolePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         // invalidate the cache for all objects of this type, since we have no
         // way of knowing (without running a query) what objects should be invalidated
         // from the cache based on this Criteria.
         RolePeer::clearInstancePool();
         // rename for clarity
         $criteria = clone $values;
     } elseif ($values instanceof Role) {
         // invalidate the cache for this single object
         RolePeer::removeInstanceFromPool($values);
         // create criteria based on pk values
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it must be the primary key
         $criteria = new Criteria(self::DATABASE_NAME);
         $criteria->add(RolePeer::ID, (array) $values, Criteria::IN);
         foreach ((array) $values as $singleval) {
             // we can invalidate the cache for this single object
             RolePeer::removeInstanceFromPool($singleval);
         }
     }
     // Set the correct dbName
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     try {
         // use transaction because $criteria could contain info
         // for more than one table or we could emulating ON DELETE CASCADE, etc.
         $con->beginTransaction();
         $affectedRows += RolePeer::doOnDeleteCascade($criteria, $con);
         // Because this db requires some delete cascade/set null emulation, we have to
         // clear the cached instance *after* the emulation has happened (since
         // instances get re-added by the select statement contained therein).
         if ($values instanceof Criteria) {
             RolePeer::clearInstancePool();
         } else {
             // it's a PK or object
             RolePeer::removeInstanceFromPool($values);
         }
         $affectedRows += BasePeer::doDelete($criteria, $con);
         // invalidate objects in EmployeePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         EmployeePeer::clearInstancePool();
         // invalidate objects in UserPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         UserPeer::clearInstancePool();
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
 /**
  * Performs a DELETE on the database, given a Proveedor or Criteria object OR a primary key value.
  *
  * @param      mixed $values Criteria or Proveedor object or primary key or array of primary keys
  *              which is used to create the DELETE statement
  * @param      PropelPDO $con the connection to use
  * @return     int 	The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
  *				if supported by native driver or if emulated using Propel.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(ProveedorPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         // rename for clarity
         $criteria = clone $values;
     } elseif ($values instanceof Proveedor) {
         // it's a model object
         // create criteria based on pk values
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it's a primary key, or an array of pks
         $criteria = new Criteria(self::DATABASE_NAME);
         $criteria->add(ProveedorPeer::IDPROVEEDOR, (array) $values, Criteria::IN);
     }
     // Set the correct dbName
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     try {
         // use transaction because $criteria could contain info
         // for more than one table or we could emulating ON DELETE CASCADE, etc.
         $con->beginTransaction();
         // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
         $c = clone $criteria;
         $affectedRows += ProveedorPeer::doOnDeleteCascade($c, $con);
         // Because this db requires some delete cascade/set null emulation, we have to
         // clear the cached instance *after* the emulation has happened (since
         // instances get re-added by the select statement contained therein).
         if ($values instanceof Criteria) {
             ProveedorPeer::clearInstancePool();
         } elseif ($values instanceof Proveedor) {
             // it's a model object
             ProveedorPeer::removeInstanceFromPool($values);
         } else {
             // it's a primary key, or an array of pks
             foreach ((array) $values as $singleval) {
                 ProveedorPeer::removeInstanceFromPool($singleval);
             }
         }
         $affectedRows += BasePeer::doDelete($criteria, $con);
         ProveedorPeer::clearRelatedInstancePool();
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Example #7
0
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(TipodocentePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         TipodocentePeer::clearInstancePool();
         $criteria = clone $values;
     } elseif ($values instanceof Tipodocente) {
         TipodocentePeer::removeInstanceFromPool($values);
         $criteria = $values->buildPkeyCriteria();
     } else {
         $criteria = new Criteria(self::DATABASE_NAME);
         $criteria->add(TipodocentePeer::ID, (array) $values, Criteria::IN);
         foreach ((array) $values as $singleval) {
             TipodocentePeer::removeInstanceFromPool($singleval);
         }
     }
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     try {
         $con->beginTransaction();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Example #8
0
 public static function doDelete($values, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(VCourseDayPeer::DATABASE_NAME);
     }
     if ($values instanceof Criteria) {
         $criteria = clone $values;
     } elseif ($values instanceof VCourseDay) {
         $criteria = $values->buildCriteria();
     } else {
         $criteria = new Criteria(self::DATABASE_NAME);
         if (count($values) == count($values, COUNT_RECURSIVE)) {
             $values = array($values);
         }
         $vals = array();
         foreach ($values as $value) {
         }
     }
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     try {
         $con->begin();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }
Example #9
0
 public static function doSelectWithTitle(Criteria $c, $culture = null, $include_unpublished_pages = false, $con = null)
 {
     $dbMap = Propel::getDatabaseMap($c->getDbName());
     if ($con === null) {
         $con = Propel::getConnection($c->getDbName());
     }
     if ($culture === null) {
         $culture = sfContext::getInstance()->getUser()->getCulture();
     }
     // Set the correct dbName if it has not been overridden
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     self::addSelectColumns($c);
     $startcol = self::NUM_COLUMNS - self::NUM_LAZY_LOAD_COLUMNS + 1;
     $c->addSelectColumn(sfSimpleCMSSlotPeer::VALUE);
     if (!$include_unpublished_pages) {
         $c->add(self::IS_PUBLISHED, true);
     }
     // Start of the complicated stuff
     // ------------------------------
     // big hack to have the join operate on three conditions
     $c->addJoin(sfSimpleCMSSlotPeer::PAGE_ID, sfSimpleCMSPagePeer::ID . ' AND ' . sfSimpleCMSSlotPeer::CULTURE . ' = ? AND ' . sfSimpleCMSSlotPeer::NAME . ' = \'title\'', Criteria::RIGHT_JOIN);
     // but now we need to populate the statement by hand
     $params = array();
     $sql = BasePeer::createSelectSql($c, $params);
     array_unshift($params, array('column' => sfSimpleCMSSlotPeer::CULTURE, 'table' => sfSimpleCMSSlotPeer::TABLE_NAME, 'value' => $culture));
     $stmt = $con->prepareStatement($sql);
     $stmt->setLimit($c->getLimit());
     $stmt->setOffset($c->getOffset());
     $i = 1;
     foreach ($params as $param) {
         $tableName = $param['table'];
         $columnName = $param['column'];
         $value = $param['value'];
         if ($value === null) {
             $stmt->setNull($i++);
         } else {
             $cMap = $dbMap->getTable($tableName)->getColumn($columnName);
             $setter = 'set' . CreoleTypes::getAffix($cMap->getCreoleType());
             $stmt->{$setter}($i++, $value);
         }
     }
     $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
     // ----------------------------
     // End of the complicated stuff
     /*
     // The complicated code above is there just to add a join on the three conditions 
     // It could be achieved in a simpler way with these lines
     $c->addJoin(sfSimpleCMSSlotPeer::PAGE_ID, sfSimpleCMSPagePeer::ID, Criteria::RIGHT_JOIN);
     $c->add(sfSimpleCMSSlotPeer::CULTURE, $culture);
     $c->add(sfSimpleCMSSlotPeer::NAME, 'title');
     // But then pages with no title would not be visible in menus
     // So we do it with more code and it's both safe and functional
     */
     $results = array();
     while ($rs->next()) {
         $page = new sfSimpleCMSPage();
         $page->hydrate($rs);
         //$page->setCulture($culture);
         $page->setTitle($rs->getString($startcol));
         $results[] = $page;
     }
     return $results;
 }
 /**
  * Method perform a DELETE on the database, given a ExamCommentDig or Criteria object OR a primary key value.
  *
  * @param      mixed $values Criteria or ExamCommentDig object or primary key or array of primary keys
  *              which is used to create the DELETE statement
  * @param      PropelPDO $con the connection to use
  * @return     int 	The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
  *				if supported by native driver or if emulated using Propel.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(ExamCommentDigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         // invalidate the cache for all objects of this type, since we have no
         // way of knowing (without running a query) what objects should be invalidated
         // from the cache based on this Criteria.
         ExamCommentDigPeer::clearInstancePool();
         // rename for clarity
         $criteria = clone $values;
     } elseif ($values instanceof ExamCommentDig) {
         // invalidate the cache for this single object
         ExamCommentDigPeer::removeInstanceFromPool($values);
         // create criteria based on pk values
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it must be the primary key
         $criteria = new Criteria(self::DATABASE_NAME);
         // primary key is composite; we therefore, expect
         // the primary key passed to be an array of pkey
         // values
         if (count($values) == count($values, COUNT_RECURSIVE)) {
             // array is not multi-dimensional
             $values = array($values);
         }
         foreach ($values as $value) {
             $criterion = $criteria->getNewCriterion(ExamCommentDigPeer::IP, $value[0]);
             $criterion->addAnd($criteria->getNewCriterion(ExamCommentDigPeer::COMMENT_ID, $value[1]));
             $criteria->addOr($criterion);
             // we can invalidate the cache for this single PK
             ExamCommentDigPeer::removeInstanceFromPool($value);
         }
     }
     // Set the correct dbName
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     try {
         // use transaction because $criteria could contain info
         // for more than one table or we could emulating ON DELETE CASCADE, etc.
         $con->beginTransaction();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Example #11
0
 public static function doDelete($values, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(EtimeAudiencePeer::DATABASE_NAME);
     }
     if ($values instanceof Criteria) {
         $criteria = clone $values;
     } elseif ($values instanceof EtimeAudience) {
         $criteria = $values->buildPkeyCriteria();
     } else {
         $criteria = new Criteria(self::DATABASE_NAME);
         if (count($values) == count($values, COUNT_RECURSIVE)) {
             $values = array($values);
         }
         $vals = array();
         foreach ($values as $value) {
             $vals[0][] = $value[0];
             $vals[1][] = $value[1];
         }
         $criteria->add(EtimeAudiencePeer::ETIME_ID, $vals[0], Criteria::IN);
         $criteria->add(EtimeAudiencePeer::AUDIENCE_ID, $vals[1], Criteria::IN);
     }
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     try {
         $con->begin();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }
Example #12
0
 /**
  * Performs a DELETE on the database, given a Traspaso or Criteria object OR a primary key value.
  *
  * @param      mixed $values Criteria or Traspaso object or primary key or array of primary keys
  *              which is used to create the DELETE statement
  * @param      PropelPDO $con the connection to use
  * @return int The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
  *				if supported by native driver or if emulated using Propel.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(TraspasoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         // rename for clarity
         $criteria = clone $values;
     } elseif ($values instanceof Traspaso) {
         // it's a model object
         // create criteria based on pk values
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it's a primary key, or an array of pks
         $criteria = new Criteria(TraspasoPeer::DATABASE_NAME);
         // primary key is composite; we therefore, expect
         // the primary key passed to be an array of pkey values
         if (count($values) == count($values, COUNT_RECURSIVE)) {
             // array is not multi-dimensional
             $values = array($values);
         }
         foreach ($values as $value) {
             $criterion = $criteria->getNewCriterion(TraspasoPeer::IDINVENTARIOLUGAR, $value[0]);
             $criterion->addAnd($criteria->getNewCriterion(TraspasoPeer::IDLUGARREMITENTE, $value[1]));
             $criterion->addAnd($criteria->getNewCriterion(TraspasoPeer::IDLUGARDESTINATARIO, $value[2]));
             $criteria->addOr($criterion);
         }
     }
     // Set the correct dbName
     $criteria->setDbName(TraspasoPeer::DATABASE_NAME);
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     try {
         // use transaction because $criteria could contain info
         // for more than one table or we could emulating ON DELETE CASCADE, etc.
         $con->beginTransaction();
         // cloning the Criteria in case it's modified by doSelect() or doSelectStmt()
         $c = clone $criteria;
         $affectedRows += TraspasoPeer::doOnDeleteCascade($c, $con);
         // Because this db requires some delete cascade/set null emulation, we have to
         // clear the cached instance *after* the emulation has happened (since
         // instances get re-added by the select statement contained therein).
         if ($values instanceof Criteria) {
             TraspasoPeer::clearInstancePool();
         } elseif ($values instanceof Traspaso) {
             // it's a model object
             TraspasoPeer::removeInstanceFromPool($values);
         } else {
             // it's a primary key, or an array of pks
             foreach ((array) $values as $singleval) {
                 TraspasoPeer::removeInstanceFromPool($singleval);
             }
         }
         $affectedRows += BasePeer::doDelete($criteria, $con);
         TraspasoPeer::clearRelatedInstancePool();
         $con->commit();
         return $affectedRows;
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(RelAnioActividadDocentePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         RelAnioActividadDocentePeer::clearInstancePool();
         $criteria = clone $values;
     } elseif ($values instanceof RelAnioActividadDocente) {
         RelAnioActividadDocentePeer::removeInstanceFromPool($values);
         $criteria = $values->buildPkeyCriteria();
     } else {
         $criteria = new Criteria(self::DATABASE_NAME);
         if (count($values) == count($values, COUNT_RECURSIVE)) {
             $values = array($values);
         }
         foreach ($values as $value) {
             $criterion = $criteria->getNewCriterion(RelAnioActividadDocentePeer::FK_ANIO_ACTIVIDAD_ID, $value[0]);
             $criterion->addAnd($criteria->getNewCriterion(RelAnioActividadDocentePeer::FK_DOCENTE_ID, $value[1]));
             $criteria->addOr($criterion);
             RelAnioActividadDocentePeer::removeInstanceFromPool($value);
         }
     }
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     try {
         $con->beginTransaction();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Example #14
0
 public static function doDelete($values, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(VSubjectAgendaPeer::DATABASE_NAME);
     }
     if ($values instanceof Criteria) {
         $criteria = clone $values;
     } elseif ($values instanceof VSubjectAgenda) {
         $criteria = $values->buildPkeyCriteria();
     } else {
         $criteria = new Criteria(self::DATABASE_NAME);
         if (count($values) == count($values, COUNT_RECURSIVE)) {
             $values = array($values);
         }
         $vals = array();
         foreach ($values as $value) {
             $vals[0][] = $value[0];
             $vals[1][] = $value[1];
             $vals[2][] = $value[2];
             $vals[3][] = $value[3];
         }
         $criteria->add(VSubjectAgendaPeer::COURSE_SCHEDULE_ID, $vals[0], Criteria::IN);
         $criteria->add(VSubjectAgendaPeer::CLASS_GROUP_ID, $vals[1], Criteria::IN);
         $criteria->add(VSubjectAgendaPeer::SUBJECT_CURR_ID, $vals[2], Criteria::IN);
         $criteria->add(VSubjectAgendaPeer::ACADEMIC_CALENDAR_ID, $vals[3], Criteria::IN);
     }
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     try {
         $con->begin();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }
Example #15
0
 /**
  * Method perform a DELETE on the database, given a sfAsset or Criteria object OR a primary key value.
  *
  * @param      mixed $values Criteria or sfAsset object or primary key or array of primary keys
  *              which is used to create the DELETE statement
  * @param      PropelPDO $con the connection to use
  * @return     int 	The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
  *				if supported by native driver or if emulated using Propel.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(sfAssetPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         // invalidate the cache for all objects of this type, since we have no
         // way of knowing (without running a query) what objects should be invalidated
         // from the cache based on this Criteria.
         sfAssetPeer::clearInstancePool();
         // rename for clarity
         $criteria = clone $values;
     } elseif ($values instanceof sfAsset) {
         // invalidate the cache for this single object
         sfAssetPeer::removeInstanceFromPool($values);
         // create criteria based on pk values
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it must be the primary key
         $criteria = new Criteria(self::DATABASE_NAME);
         $criteria->add(sfAssetPeer::ID, (array) $values, Criteria::IN);
         foreach ((array) $values as $singleval) {
             // we can invalidate the cache for this single object
             sfAssetPeer::removeInstanceFromPool($singleval);
         }
     }
     // Set the correct dbName
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     try {
         // use transaction because $criteria could contain info
         // for more than one table or we could emulating ON DELETE CASCADE, etc.
         $con->beginTransaction();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }
Example #16
0
 public static function doDelete($values, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(VOpacPeer::DATABASE_NAME);
     }
     if ($values instanceof Criteria) {
         $criteria = clone $values;
     } elseif ($values instanceof VOpac) {
         $criteria = $values->buildPkeyCriteria();
     } else {
         $criteria = new Criteria(self::DATABASE_NAME);
         if (count($values) == count($values, COUNT_RECURSIVE)) {
             $values = array($values);
         }
         $vals = array();
         foreach ($values as $value) {
             $vals[0][] = $value[0];
             $vals[1][] = $value[1];
             $vals[2][] = $value[2];
             $vals[3][] = $value[3];
             $vals[4][] = $value[4];
         }
         $criteria->add(VOpacPeer::CATALOG_ID, $vals[0], Criteria::IN);
         $criteria->add(VOpacPeer::DEPARTMENT_ID, $vals[1], Criteria::IN);
         $criteria->add(VOpacPeer::CAT_CATEGORY_ID, $vals[2], Criteria::IN);
         $criteria->add(VOpacPeer::COL_STATUS_ID, $vals[3], Criteria::IN);
         $criteria->add(VOpacPeer::COL_LOCATION_ID, $vals[4], Criteria::IN);
     }
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     try {
         $con->begin();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }
 /**
  * Method perform a DELETE on the database, given a BpmnProject or Criteria object OR a primary key value.
  *
  * @param      mixed $values Criteria or BpmnProject object or primary key or array of primary keys
  *              which is used to create the DELETE statement
  * @param      Connection $con the connection to use
  * @return     int  The number of affected rows (if supported by underlying database driver).
  *             This includes CASCADE-related rows
  *              if supported by native driver or if emulated using Propel.
  * @throws     PropelException Any exceptions caught during processing will be
  *       rethrown wrapped into a PropelException.
  */
 public static function doDelete($values, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(BpmnProjectPeer::DATABASE_NAME);
     }
     if ($values instanceof Criteria) {
         $criteria = clone $values;
         // rename for clarity
     } elseif ($values instanceof BpmnProject) {
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it must be the primary key
         $criteria = new Criteria(self::DATABASE_NAME);
         $criteria->add(BpmnProjectPeer::PRJ_UID, (array) $values, Criteria::IN);
     }
     // Set the correct dbName
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     try {
         // use transaction because $criteria could contain info
         // for more than one table or we could emulating ON DELETE CASCADE, etc.
         $con->begin();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }
Example #18
0
 /**
  * Method perform a DELETE on the database, given a AppOwner or Criteria object OR a primary key value.
  *
  * @param      mixed $values Criteria or AppOwner object or primary key or array of primary keys
  *              which is used to create the DELETE statement
  * @param      Connection $con the connection to use
  * @return     int 	The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
  *				if supported by native driver or if emulated using Propel.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doDelete($values, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(AppOwnerPeer::DATABASE_NAME);
     }
     if ($values instanceof Criteria) {
         $criteria = clone $values;
         // rename for clarity
     } elseif ($values instanceof AppOwner) {
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it must be the primary key
         $criteria = new Criteria(self::DATABASE_NAME);
         // primary key is composite; we therefore, expect
         // the primary key passed to be an array of pkey
         // values
         if (count($values) == count($values, COUNT_RECURSIVE)) {
             // array is not multi-dimensional
             $values = array($values);
         }
         $vals = array();
         foreach ($values as $value) {
             $vals[0][] = $value[0];
             $vals[1][] = $value[1];
             $vals[2][] = $value[2];
         }
         $criteria->add(AppOwnerPeer::APP_UID, $vals[0], Criteria::IN);
         $criteria->add(AppOwnerPeer::OWN_UID, $vals[1], Criteria::IN);
         $criteria->add(AppOwnerPeer::USR_UID, $vals[2], Criteria::IN);
     }
     // Set the correct dbName
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     try {
         // use transaction because $criteria could contain info
         // for more than one table or we could emulating ON DELETE CASCADE, etc.
         $con->begin();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }
 public static function doDelete($values, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(LorfieldsPeer::DATABASE_NAME);
     }
     if ($values instanceof Criteria) {
         $criteria = clone $values;
     } elseif ($values instanceof Lorfields) {
         $criteria = $values->buildPkeyCriteria();
     } else {
         $criteria = new Criteria(self::DATABASE_NAME);
         $criteria->add(LorfieldsPeer::ID, (array) $values, Criteria::IN);
     }
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     try {
         $con->begin();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }
 public static function doDelete($values, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(CounselingRaportPeer::DATABASE_NAME);
     }
     if ($values instanceof Criteria) {
         $criteria = clone $values;
     } elseif ($values instanceof CounselingRaport) {
         $criteria = $values->buildPkeyCriteria();
     } else {
         $criteria = new Criteria(self::DATABASE_NAME);
         if (count($values) == count($values, COUNT_RECURSIVE)) {
             $values = array($values);
         }
         $vals = array();
         foreach ($values as $value) {
             $vals[0][] = $value[0];
             $vals[1][] = $value[1];
             $vals[2][] = $value[2];
             $vals[3][] = $value[3];
         }
         $criteria->add(CounselingRaportPeer::ID, $vals[0], Criteria::IN);
         $criteria->add(CounselingRaportPeer::STUDENT_ACCAL_ID, $vals[1], Criteria::IN);
         $criteria->add(CounselingRaportPeer::SUBJECT_CURR_ID, $vals[2], Criteria::IN);
         $criteria->add(CounselingRaportPeer::COUNSELING_SPEC_ID, $vals[3], Criteria::IN);
     }
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     try {
         $con->begin();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
 }