/** * 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(); }
/** * Filter the query on the confirmation column * * @param mixed $confirmation The value to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return PrincipalQuery The current query, for fluid interface * @throws PropelException - if the value is not accepted by the enum. */ public function filterByConfirmation($confirmation = null, $comparison = null) { if (is_scalar($confirmation)) { $confirmation = PrincipalPeer::getSqlValueForEnum(PrincipalPeer::CONFIRMATION, $confirmation); } elseif (is_array($confirmation)) { $convertedValues = array(); foreach ($confirmation as $value) { $convertedValues[] = PrincipalPeer::getSqlValueForEnum(PrincipalPeer::CONFIRMATION, $value); } $confirmation = $convertedValues; if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(PrincipalPeer::CONFIRMATION, $confirmation, $comparison); }
/** * Selects a collection of PrincipalI18n objects pre-filled with all related objects. * * @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 PrincipalI18n objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(PrincipalI18nPeer::DATABASE_NAME); } PrincipalI18nPeer::addSelectColumns($criteria); $startcol2 = PrincipalI18nPeer::NUM_HYDRATE_COLUMNS; PrincipalPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + PrincipalPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(PrincipalI18nPeer::ID, PrincipalPeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = PrincipalI18nPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = PrincipalI18nPeer::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 = PrincipalI18nPeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); PrincipalI18nPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Principal rows $key2 = PrincipalPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = PrincipalPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = PrincipalPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); PrincipalPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (PrincipalI18n) to the collection in $obj2 (Principal) $obj2->addPrincipalI18n($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * 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 Principal 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(PrincipalPeer::DATABASE_NAME); } if ($newRank < 1 || $newRank > PrincipalQuery::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; PrincipalPeer::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; } }
/** * 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(PrincipalPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $whereCriteria = PrincipalQuery::create(); if (null !== $first) { $whereCriteria->add(PrincipalPeer::RANK_COL, $first, Criteria::GREATER_EQUAL); } if (null !== $last) { $whereCriteria->addAnd(PrincipalPeer::RANK_COL, $last, Criteria::LESS_EQUAL); } $valuesCriteria = new Criteria(PrincipalPeer::DATABASE_NAME); $valuesCriteria->add(PrincipalPeer::RANK_COL, array('raw' => PrincipalPeer::RANK_COL . ' + ?', 'value' => $delta), Criteria::CUSTOM_EQUAL); BasePeer::doUpdate($whereCriteria, $valuesCriteria, $con); PrincipalPeer::clearInstancePool(); }
/** * Method to invalidate the instance pool of all tables related to fos_user * by a foreign key with ON DELETE CASCADE */ public static function clearRelatedInstancePool() { // Invalidate objects in AreaAssignmentPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. AreaAssignmentPeer::clearInstancePool(); // Invalidate objects in UserLogPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserLogPeer::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 ProductAssignmentPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. ProductAssignmentPeer::clearInstancePool(); // Invalidate objects in VisitationPeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. VisitationPeer::clearInstancePool(); // Invalidate objects in UserProfilePeer instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. UserProfilePeer::clearInstancePool(); }
/** * Selects a collection of UserProfile 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 UserProfile 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(UserProfilePeer::DATABASE_NAME); } UserProfilePeer::addSelectColumns($criteria); $startcol2 = UserProfilePeer::NUM_HYDRATE_COLUMNS; StatePeer::addSelectColumns($criteria); $startcol3 = $startcol2 + StatePeer::NUM_HYDRATE_COLUMNS; CountryPeer::addSelectColumns($criteria); $startcol4 = $startcol3 + CountryPeer::NUM_HYDRATE_COLUMNS; PrincipalPeer::addSelectColumns($criteria); $startcol5 = $startcol4 + PrincipalPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(UserProfilePeer::STATE_ID, StatePeer::ID, $join_behavior); $criteria->addJoin(UserProfilePeer::COUNTRY_ID, CountryPeer::ID, $join_behavior); $criteria->addJoin(UserProfilePeer::PRINCIPAL_ID, PrincipalPeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = UserProfilePeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = UserProfilePeer::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 = UserProfilePeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); UserProfilePeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined State rows $key2 = StatePeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = StatePeer::getInstanceFromPool($key2); if (!$obj2) { $cls = StatePeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); StatePeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (UserProfile) to the collection in $obj2 (State) $obj2->addUserProfile($obj1); } // if joined row is not null // Add objects for joined Country rows $key3 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = CountryPeer::getInstanceFromPool($key3); if (!$obj3) { $cls = CountryPeer::getOMClass(); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); CountryPeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded // Add the $obj1 (UserProfile) to the collection in $obj3 (Country) $obj3->addUserProfile($obj1); } // if joined row is not null // Add objects for joined Principal rows $key4 = PrincipalPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = PrincipalPeer::getInstanceFromPool($key4); if (!$obj4) { $cls = PrincipalPeer::getOMClass(); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); PrincipalPeer::addInstanceToPool($obj4, $key4); } // if $obj4 already loaded // Add the $obj1 (UserProfile) to the collection in $obj4 (Principal) $obj4->addUserProfile($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }