/** * Adds $delta to all Rank values that are >= $first and <= $last. * '$delta' can also be negative. * * @param int $delta Value to be shifted by, can be negative * @param int $first First node to be shifted * @param int $last Last node to be shifted * @param PropelPDO $con Connection to use. */ public static function shiftRank($delta, $first = null, $last = null, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(StorePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $whereCriteria = StoreQuery::create(); if (null !== $first) { $whereCriteria->add(StorePeer::RANK_COL, $first, Criteria::GREATER_EQUAL); } if (null !== $last) { $whereCriteria->addAnd(StorePeer::RANK_COL, $last, Criteria::LESS_EQUAL); } $valuesCriteria = new Criteria(StorePeer::DATABASE_NAME); $valuesCriteria->add(StorePeer::RANK_COL, array('raw' => StorePeer::RANK_COL . ' + ?', 'value' => $delta), Criteria::CUSTOM_EQUAL); BasePeer::doUpdate($whereCriteria, $valuesCriteria, $con); StorePeer::clearInstancePool(); }
/** * Method to invalidate the instance pool of all tables related to state * by a foreign key with ON DELETE CASCADE */ public static function clearRelatedInstancePool() { // Invalidate objects in CityPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. CityPeer::clearInstancePool(); // Invalidate objects in AreaPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. AreaPeer::clearInstancePool(); // Invalidate objects in PrincipalPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. PrincipalPeer::clearInstancePool(); // Invalidate objects in StorePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. StorePeer::clearInstancePool(); }
/** * Move the object to a new rank, and shifts the rank * Of the objects inbetween the old and new rank accordingly * * @param integer $newRank rank value * @param PropelPDO $con optional connection * * @return Store the current object * * @throws PropelException */ public function moveToRank($newRank, PropelPDO $con = null) { if ($this->isNew()) { throw new PropelException('New objects cannot be moved. Please use insertAtRank() instead'); } if ($con === null) { $con = Propel::getConnection(StorePeer::DATABASE_NAME); } if ($newRank < 1 || $newRank > StoreQuery::create()->getMaxRankArray($con)) { throw new PropelException('Invalid rank ' . $newRank); } $oldRank = $this->getSortableRank(); if ($oldRank == $newRank) { return $this; } $con->beginTransaction(); try { // shift the objects between the old and the new rank $delta = $oldRank < $newRank ? -1 : 1; StorePeer::shiftRank($delta, min($oldRank, $newRank), max($oldRank, $newRank), $con); // move the object to its new rank $this->setSortableRank($newRank); $this->save($con); $con->commit(); return $this; } catch (Exception $e) { $con->rollback(); throw $e; } }
/** * Method to invalidate the instance pool of all tables related to region * by a foreign key with ON DELETE CASCADE */ public static function clearRelatedInstancePool() { // Invalidate objects in BranchCoveragePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. BranchCoveragePeer::clearInstancePool(); // Invalidate objects in StorePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. StorePeer::clearInstancePool(); }
/** * Selects a collection of Visitation objects pre-filled with all related objects except User. * * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Visitation objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptUser(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden // $criteria->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(VisitationPeer::DATABASE_NAME); } VisitationPeer::addSelectColumns($criteria); $startcol2 = VisitationPeer::NUM_HYDRATE_COLUMNS; StorePeer::addSelectColumns($criteria); $startcol3 = $startcol2 + StorePeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(VisitationPeer::STORE_ID, StorePeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = VisitationPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = VisitationPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = VisitationPeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); VisitationPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Store rows $key2 = StorePeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = StorePeer::getInstanceFromPool($key2); if (!$obj2) { $cls = StorePeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); StorePeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Visitation) to the collection in $obj2 (Store) $obj2->addVisitation($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Filter the query on the store_type column * * @param mixed $storeType The value to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return StoreQuery The current query, for fluid interface * @throws PropelException - if the value is not accepted by the enum. */ public function filterByStoreType($storeType = null, $comparison = null) { if (is_scalar($storeType)) { $storeType = StorePeer::getSqlValueForEnum(StorePeer::STORE_TYPE, $storeType); } elseif (is_array($storeType)) { $convertedValues = array(); foreach ($storeType as $value) { $convertedValues[] = StorePeer::getSqlValueForEnum(StorePeer::STORE_TYPE, $value); } $storeType = $convertedValues; if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(StorePeer::STORE_TYPE, $storeType, $comparison); }