Exemplo n.º 1
0
 public function testSetJoinType()
 {
     $j = new Join();
     $j->setJoinType('foo');
     $this->assertEquals('foo', $j->getJoinType());
 }
Exemplo n.º 2
0
	/**
	 * Add a join with multiple conditions
	 * see http://propel.phpdb.org/trac/ticket/167, http://propel.phpdb.org/trac/ticket/606
	 *
	 * Example usage:
	 * $c->addMultipleJoin(array(
	 *     array(LeftPeer::LEFT_COLUMN, RightPeer::RIGHT_COLUMN),  // if no third argument, defaults to Criteria::EQUAL
	 *     array(FoldersPeer::alias( 'fo', FoldersPeer::LFT ), FoldersPeer::alias( 'parent', FoldersPeer::RGT ), Criteria::LESS_EQUAL )
	 *   ),
	 *   Criteria::LEFT_JOIN
 	 * );
	 *
	 * @see        addJoin()
	 * @param      array $conditions An array of conditions, each condition being an array (left, right, operator)
	 * @param      string $joinType  A String with the join operator. Defaults to an implicit join.
	 *
	 * @return     Criteria A modified Criteria object.
	 */
	public function addMultipleJoin($conditions, $joinType = null)
  {
		$join = new Join();
		foreach ($conditions as $condition) {
		  $join->addCondition($condition[0], $condition[1], isset($condition[2]) ? $condition[2] : Criteria::EQUAL);
		}
		$join->setJoinType($joinType);

		return $this->addJoinObject($join);
	}
Exemplo n.º 3
0
 /**
  * Add a join with multiple conditions
  * @deprecated use Join::setJoinCondition($criterion) instead
  *
  * @see http://propel.phpdb.org/trac/ticket/167, http://propel.phpdb.org/trac/ticket/606
  *
  * Example usage:
  * $c->addMultipleJoin(array(
  *     array(LeftPeer::LEFT_COLUMN, RightPeer::RIGHT_COLUMN),  // if no third argument, defaults to Criteria::EQUAL
  *     array(FoldersPeer::alias( 'fo', FoldersPeer::LFT ), FoldersPeer::alias( 'parent', FoldersPeer::RGT ), Criteria::LESS_EQUAL )
  *   ),
  *   Criteria::LEFT_JOIN
  * );
  *
  * @see        addJoin()
  * @param      array $conditions An array of conditions, each condition being an array (left, right, operator)
  * @param      string $joinType  A String with the join operator. Defaults to an implicit join.
  *
  * @return     Criteria A modified Criteria object.
  */
 public function addMultipleJoin($conditions, $joinType = null)
 {
     $join = new Join();
     $joinCondition = null;
     foreach ($conditions as $condition) {
         $left = $condition[0];
         $right = $condition[1];
         if ($pos = strrpos($left, '.')) {
             $leftTableAlias = substr($left, 0, $pos);
             $leftColumnName = substr($left, $pos + 1);
             list($leftTableName, $leftTableAlias) = $this->getTableNameAndAlias($leftTableAlias);
         } else {
             list($leftTableName, $leftTableAlias) = array(null, null);
             $leftColumnName = $left;
         }
         if ($pos = strrpos($right, '.')) {
             $rightTableAlias = substr($right, 0, $pos);
             $rightColumnName = substr($right, $pos + 1);
             list($rightTableName, $rightTableAlias) = $this->getTableNameAndAlias($rightTableAlias);
         } else {
             list($rightTableName, $rightTableAlias) = array(null, null);
             $rightColumnName = $right;
         }
         if (!$join->getRightTableName()) {
             $join->setRightTableName($rightTableName);
         }
         if (!$join->getRightTableAlias()) {
             $join->setRightTableAlias($rightTableAlias);
         }
         $conditionClause = $leftTableAlias ? $leftTableAlias . '.' : ($leftTableName ? $leftTableName . '.' : '');
         $conditionClause .= $leftColumnName;
         $conditionClause .= isset($condition[2]) ? $condition[2] : JOIN::EQUAL;
         $conditionClause .= $rightTableAlias ? $rightTableAlias . '.' : ($rightTableName ? $rightTableName . '.' : '');
         $conditionClause .= $rightColumnName;
         $criterion = $this->getNewCriterion($leftTableName . '.' . $leftColumnName, $conditionClause, Criteria::CUSTOM);
         if (null === $joinCondition) {
             $joinCondition = $criterion;
         } else {
             $joinCondition = $joinCondition->addAnd($criterion);
         }
     }
     $join->setJoinType($joinType);
     $join->setJoinCondition($joinCondition);
     return $this->addJoinObject($join);
 }
Exemplo n.º 4
0
 protected static function deleteOldVersionedFileSyncs($objectType, $objectSubType)
 {
     if (!isset(self::$oldVersionsStartUpdatedAt[$objectType])) {
         self::$oldVersionsStartUpdatedAt[$objectType] = 0;
     }
     if (!isset(self::$oldVersionsEndUpdatedAt[$objectType])) {
         self::$oldVersionsEndUpdatedAt[$objectType] = 0;
     }
     $criteria = new Criteria();
     switch ($objectType) {
         case FileSyncObjectType::ASSET:
             if ($objectSubType != asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET) {
                 return array();
             }
             $join = new Join();
             $join->addCondition(FileSyncPeer::OBJECT_ID, assetPeer::ID);
             $join->addCondition(FileSyncPeer::VERSION, assetPeer::VERSION, Criteria::NOT_EQUAL);
             $join->setJoinType(Criteria::LEFT_JOIN);
             $criteria->addJoinObject($join);
             $criteria->add(assetPeer::VERSION, null, Criteria::ISNOTNULL);
             break;
         case FileSyncObjectType::UICONF:
             $join = new Join();
             $join->addCondition(FileSyncPeer::OBJECT_ID, uiConfPeer::ID);
             $join->addCondition(FileSyncPeer::VERSION, uiConfPeer::VERSION, Criteria::NOT_EQUAL);
             $join->setJoinType(Criteria::LEFT_JOIN);
             $criteria->addJoinObject($join);
             $criteria->add(uiConfPeer::VERSION, null, Criteria::ISNOTNULL);
             break;
         case FileSyncObjectType::ENTRY:
             $join = new Join();
             $join->addCondition(FileSyncPeer::OBJECT_ID, entryPeer::ID);
             switch ($objectSubType) {
                 case entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB:
                     $join->addCondition(FileSyncPeer::VERSION, entryPeer::THUMBNAIL, Criteria::NOT_EQUAL);
                     $criteria->add(entryPeer::THUMBNAIL, null, Criteria::ISNOTNULL);
                     break;
                 case entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA:
                 case entry::FILE_SYNC_ENTRY_SUB_TYPE_DOWNLOAD:
                     $join->addCondition(FileSyncPeer::VERSION, entryPeer::DATA, Criteria::NOT_EQUAL);
                     $criteria->add(entryPeer::DATA, null, Criteria::ISNOTNULL);
                     break;
                 default:
                     return array();
             }
             $join->setJoinType(Criteria::LEFT_JOIN);
             $criteria->addJoinObject($join);
             break;
         case FileSyncObjectType::METADATA:
             $join = new Join();
             $join->addCondition(FileSyncPeer::OBJECT_ID, MetadataPeer::ID);
             $join->addCondition(FileSyncPeer::VERSION, MetadataPeer::VERSION, Criteria::NOT_EQUAL);
             $join->setJoinType(Criteria::LEFT_JOIN);
             $criteria->addJoinObject($join);
             $criteria->add(MetadataPeer::VERSION, null, Criteria::ISNOTNULL);
             break;
         case FileSyncObjectType::METADATA_PROFILE:
             $join = new Join();
             $join->addCondition(FileSyncPeer::OBJECT_ID, MetadataProfilePeer::ID);
             switch ($objectSubType) {
                 case MetadataProfile::FILE_SYNC_METADATA_DEFINITION:
                     $join->addCondition(FileSyncPeer::VERSION, MetadataProfilePeer::FILE_SYNC_VERSION, Criteria::NOT_EQUAL);
                     $criteria->add(MetadataProfilePeer::FILE_SYNC_VERSION, null, Criteria::ISNOTNULL);
                     break;
                 case MetadataProfile::FILE_SYNC_METADATA_VIEWS:
                     $join->addCondition(FileSyncPeer::VERSION, MetadataProfilePeer::VIEWS_VERSION, Criteria::NOT_EQUAL);
                     $criteria->add(MetadataProfilePeer::VIEWS_VERSION, null, Criteria::ISNOTNULL);
                     break;
                 default:
                     return array();
             }
             $join->setJoinType(Criteria::LEFT_JOIN);
             $criteria->addJoinObject($join);
             break;
         default:
             return array();
     }
     $criteria->add(FileSyncPeer::DC, kDataCenterMgr::getCurrentDcId());
     $criteria->add(FileSyncPeer::OBJECT_TYPE, $objectType);
     $criteria->add(FileSyncPeer::OBJECT_SUB_TYPE, $objectSubType);
     $criteria->add(FileSyncPeer::STATUS, array(FileSync::FILE_SYNC_STATUS_DELETED, FileSync::FILE_SYNC_STATUS_PURGED), Criteria::NOT_IN);
     $nextCriteria = clone $criteria;
     $criteria->add(FileSyncPeer::UPDATED_AT, self::$oldVersionsStartUpdatedAt[$objectType], Criteria::GREATER_EQUAL);
     $criteria->addAnd(FileSyncPeer::UPDATED_AT, self::$oldVersionsEndUpdatedAt[$objectType], Criteria::LESS_EQUAL);
     $criteria->addAscendingOrderByColumn(FileSyncPeer::UPDATED_AT);
     $criteria->setLimit(self::$queryLimit);
     $fileSyncs = FileSyncPeer::doSelect($criteria);
     if (count($fileSyncs)) {
         foreach ($fileSyncs as $fileSync) {
             /* @var $fileSync FileSync */
             self::deleteFileSync($fileSync);
             if ($fileSync->getUpdatedAt(null)) {
                 self::$oldVersionsNextStartUpdatedAt[$objectType] = $fileSync->getUpdatedAt(null);
             }
         }
     } else {
         self::$oldVersionsNextStartUpdatedAt[$objectType] = self::$oldVersionsStartUpdatedAt[$objectType];
         $nextCriteria->add(FileSyncPeer::UPDATED_AT, self::$oldVersionsStartUpdatedAt[$objectType], Criteria::GREATER_THAN);
         $nextCriteria->addSelectColumn('UNIX_TIMESTAMP(MIN(' . FileSyncPeer::UPDATED_AT . '))');
         $stmt = FileSyncPeer::doSelectStmt($nextCriteria);
         $mins = $stmt->fetchAll(PDO::FETCH_COLUMN);
         if (count($mins)) {
             $oldVersionsNextStartUpdatedAt = reset($mins);
             if (!is_null($oldVersionsNextStartUpdatedAt)) {
                 self::$oldVersionsNextStartUpdatedAt[$objectType] = $oldVersionsNextStartUpdatedAt;
             }
         }
     }
     kMemoryManager::clearMemory();
 }