当前位置: 首页>>代码示例>>PHP>>正文


PHP Criteria::getOffset方法代码示例

本文整理汇总了PHP中Criteria::getOffset方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::getOffset方法的具体用法?PHP Criteria::getOffset怎么用?PHP Criteria::getOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Criteria的用法示例。


在下文中一共展示了Criteria::getOffset方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testMergeWithOffset

 public function testMergeWithOffset()
 {
     $c1 = new Criteria();
     $c1->setOffset(123);
     $c2 = new Criteria();
     $c1->mergeWith($c2);
     $this->assertEquals(123, $c1->getOffset(), 'mergeWith() does not remove an existing offset');
     $c1 = new Criteria();
     $c2 = new Criteria();
     $c2->setOffset(123);
     $c1->mergeWith($c2);
     $this->assertEquals(123, $c1->getOffset(), 'mergeWith() merges the offset');
     $c1 = new Criteria();
     $c1->setOffset(456);
     $c2 = new Criteria();
     $c2->setOffset(123);
     $c1->mergeWith($c2);
     $this->assertEquals(456, $c1->getOffset(), 'mergeWith() does not merge the offset in case of conflict');
 }
开发者ID:halfer,项目名称:Meshing,代码行数:19,代码来源:CriteriaMergeTest.php

示例2: doCount

 /**
  * Executes a COUNT query using either a simple SQL rewrite or, for more complex queries, a
  * sub-select of the SQL created by createSelectSql() and returns the statement.
  *
  * @param      Criteria $criteria A Criteria.
  * @param      PropelPDO $con A PropelPDO connection to use.
  * @return     PDOStatement The resultset statement.
  * @throws     PropelException
  * @see        createSelectSql()
  */
 public static function doCount(Criteria $criteria, PropelPDO $con = null)
 {
     $dbMap = Propel::getDatabaseMap($criteria->getDbName());
     $db = Propel::getDB($criteria->getDbName());
     if ($con === null) {
         $con = Propel::getConnection($criteria->getDbName(), Propel::CONNECTION_READ);
     }
     $stmt = null;
     if ($criteria->isUseTransaction()) {
         $con->beginTransaction();
     }
     $needsComplexCount = $criteria->getGroupByColumns() || $criteria->getOffset() || $criteria->getLimit() || $criteria->getHaving() || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers());
     try {
         $params = array();
         if ($needsComplexCount) {
             if (self::needsSelectAliases($criteria)) {
                 if ($criteria->getHaving()) {
                     throw new PropelException('Propel cannot create a COUNT query when using HAVING and  duplicate column names in the SELECT part');
                 }
                 self::turnSelectColumnsToAliases($criteria);
             }
             $selectSql = self::createSelectSql($criteria, $params);
             $sql = 'SELECT COUNT(*) FROM (' . $selectSql . ') propelmatch4cnt';
         } else {
             // Replace SELECT columns with COUNT(*)
             $criteria->clearSelectColumns()->addSelectColumn('COUNT(*)');
             $sql = self::createSelectSql($criteria, $params);
         }
         $stmt = $con->prepare($sql);
         self::populateStmtValues($stmt, $params, $dbMap, $db);
         $stmt->execute();
         if ($criteria->isUseTransaction()) {
             $con->commit();
         }
     } catch (Exception $e) {
         if ($stmt !== null) {
             $stmt = null;
         }
         if ($criteria->isUseTransaction()) {
             $con->rollBack();
         }
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute COUNT statement [%s]', $sql), $e);
     }
     return $stmt;
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:56,代码来源:BasePeer.php

示例3: mergeWith

 /**
  * Add the content of a Criteria to the current Criteria
  * In case of conflict, the current Criteria keeps its properties
  *
  * @param     Criteria $criteria The criteria to read properties from
  * @param     string $operator The logical operator used to combine conditions
  *            Defaults to Criteria::LOGICAL_AND, also accapts Criteria::LOGICAL_OR
  *            This parameter is deprecated, use _or() instead
  *
  * @return    Criteria The current criteria object
  */
 public function mergeWith(Criteria $criteria, $operator = null)
 {
     // merge limit
     $limit = $criteria->getLimit();
     if ($limit != 0 && $this->getLimit() == 0) {
         $this->limit = $limit;
     }
     // merge offset
     $offset = $criteria->getOffset();
     if ($offset != 0 && $this->getOffset() == 0) {
         $this->offset = $offset;
     }
     // merge select modifiers
     $selectModifiers = $criteria->getSelectModifiers();
     if ($selectModifiers && !$this->selectModifiers) {
         $this->selectModifiers = $selectModifiers;
     }
     // merge select columns
     $this->selectColumns = array_merge($this->getSelectColumns(), $criteria->getSelectColumns());
     // merge as columns
     $commonAsColumns = array_intersect_key($this->getAsColumns(), $criteria->getAsColumns());
     if (!empty($commonAsColumns)) {
         throw new PropelException('The given criteria contains an AsColumn with an alias already existing in the current object');
     }
     $this->asColumns = array_merge($this->getAsColumns(), $criteria->getAsColumns());
     // merge orderByColumns
     $orderByColumns = array_merge($this->getOrderByColumns(), $criteria->getOrderByColumns());
     $this->orderByColumns = array_unique($orderByColumns);
     // merge groupByColumns
     $groupByColumns = array_merge($this->getGroupByColumns(), $criteria->getGroupByColumns());
     $this->groupByColumns = array_unique($groupByColumns);
     // merge where conditions
     if ($operator == Criteria::LOGICAL_OR) {
         $this->_or();
     }
     $isFirstCondition = true;
     foreach ($criteria->getMap() as $key => $criterion) {
         if ($isFirstCondition && $this->defaultCombineOperator == Criteria::LOGICAL_OR) {
             $this->addOr($criterion, null, null, false);
             $this->defaultCombineOperator == Criteria::LOGICAL_AND;
         } elseif ($this->containsKey($key)) {
             $this->addAnd($criterion);
         } else {
             $this->add($criterion);
         }
         $isFirstCondition = false;
     }
     // merge having
     if ($having = $criteria->getHaving()) {
         if ($this->getHaving()) {
             $this->addHaving($this->getHaving()->addAnd($having));
         } else {
             $this->addHaving($having);
         }
     }
     // merge alias
     $commonAliases = array_intersect_key($this->getAliases(), $criteria->getAliases());
     if (!empty($commonAliases)) {
         throw new PropelException('The given criteria contains an alias already existing in the current object');
     }
     $this->aliases = array_merge($this->getAliases(), $criteria->getAliases());
     // merge join
     $this->joins = array_merge($this->getJoins(), $criteria->getJoins());
     return $this;
 }
开发者ID:homer6,项目名称:Propel,代码行数:76,代码来源:Criteria.php

示例4: createSelectSql


//.........这里部分代码省略.........
     				if (!empty($joins)) {
     					for ($i=0, $joinSize=count($joins); $i < $joinSize; $i++) {
     						$join =& $joins[$i];
     						$join1 = $join->getLeftColumn();
     						$join2 = $join->getRightColumn();
     
     						$tableName = substr($join1, 0, strpos($join1, '.'));
     						$table = $criteria->getTableForAlias($tableName);
     						if ($table !== null) {
     							$fromClause[] = $table . ' ' . $tableName;
     						} else {
     							$fromClause[] = $tableName;
     						}
     
     						$dot = strpos($join2, '.');
     						$tableName = substr($join2, 0, $dot);
     						$table = $criteria->getTableForAlias($tableName);
     						if ($table !== null) {
     							$fromClause[] = $table . ' ' . $tableName;
     						} else {
     							$fromClause[] = $tableName;
     							$table = $tableName;
     						}
     						$ignoreCase = ($criteria->isIgnoreCase() && ($dbMap->getTable($table)->getColumn(substr($join2, $dot + 1))->getType() == "string"));
     						if ($ignoreCase) {
     							$whereClause[] = $db->ignoreCase($join1) . '=' . $db->ignoreCase($join2);
     						} else {
     							$whereClause[] = $join1 . '=' . $join2;
     						}
     					if ($join->getJoinType()) {
     							$leftTable = $fromClause[count($fromClause) - 2];
     							$rightTable = $fromClause[count($fromClause) - 1];
     							$onClause = $whereClause[count($whereClause) - 1];
     							unset($whereClause[count($whereClause) - 1]);
     							$fromClause [] = $leftTable . ' ' . $join->getJoinType() . ' ' . $rightTable . ' ON ' . $onClause;
     
     							// remove all references to joinTables made by selectColumns, criteriaColumns
     							for ($i = 0, $fromClauseSize=count($fromClause); $i < $fromClauseSize; $i++) {
     								if ($fromClause[$i] == $leftTable || $fromClause[$i] == $rightTable) {
     									unset($fromClause[$i]);
     								}
     							}
     						} // If join type
     					} // Join for loop
     				} // If Joins
     */
     // Add the GROUP BY columns
     $groupByClause = $groupBy;
     $having = $criteria->getHaving();
     $havingString = null;
     if ($having !== null) {
         $sb = "";
         $having->appendPsTo($sb, $params);
         $havingString = $sb;
     }
     if (!empty($orderBy)) {
         foreach ($orderBy as $orderByColumn) {
             // Add function expression as-is.
             if (strpos($orderByColumn, '(') !== false) {
                 $orderByClause[] = $orderByColumn;
                 continue;
             }
             // Split orderByColumn (i.e. "table.column DESC")
             $dotPos = strpos($orderByColumn, '.');
             if ($dotPos !== false) {
                 $tableName = substr($orderByColumn, 0, $dotPos);
                 $columnName = substr($orderByColumn, $dotPos + 1);
             } else {
                 $tableName = '';
                 $columnName = $orderByColumn;
             }
             $spacePos = strpos($columnName, ' ');
             if ($spacePos !== false) {
                 $direction = substr($columnName, $spacePos);
                 $columnName = substr($columnName, 0, $spacePos);
             } else {
                 $direction = '';
             }
             $tableAlias = $tableName;
             if ($aliasTableName = $criteria->getTableForAlias($tableName)) {
                 $tableName = $aliasTableName;
             }
             $columnAlias = $columnName;
             if ($asColumnName = $criteria->getColumnForAs($columnName)) {
                 $columnName = $asColumnName;
             }
             $column = $tableName ? $dbMap->getTable($tableName)->getColumn($columnName) : null;
             if ($column && $column->getType() == 'string') {
                 $orderByClause[] = $db->ignoreCaseInOrderBy("{$tableAlias}.{$columnAlias}") . $direction;
                 $selectClause[] = $db->ignoreCaseInOrderBy("{$tableAlias}.{$columnAlias}");
             } else {
                 $orderByClause[] = $orderByColumn;
             }
         }
     }
     // Build the SQL from the arrays we compiled
     $sql = "SELECT " . ($selectModifiers ? implode(" ", $selectModifiers) . " " : "") . implode(", ", $selectClause) . " FROM " . (!empty($joinClause) && count($fromClause) > 1 && substr(get_class($db), 0, 7) == 'DBMySQL' ? "(" . implode(", ", $fromClause) . ")" : implode(", ", $fromClause)) . ($joinClause ? ' ' . implode(' ', $joinClause) : '') . ($whereClause ? " WHERE " . implode(" AND ", $whereClause) : "") . ($groupByClause ? " GROUP BY " . implode(",", $groupByClause) : "") . ($havingString ? " HAVING " . $havingString : "") . ($orderByClause ? " ORDER BY " . implode(",", $orderByClause) : "");
     Propel::log($sql . ' [LIMIT: ' . $criteria->getLimit() . ', OFFSET: ' . $criteria->getOffset() . ']', Propel::LOG_DEBUG);
     return $sql;
 }
开发者ID:rodrigoprestesmachado,项目名称:whiteboard,代码行数:101,代码来源:BasePeer.php

示例5: applyEntitlementCriteria

 private static function applyEntitlementCriteria(Criteria &$c)
 {
     $skipApplyFilters = false;
     if (kEntitlementUtils::getEntitlementEnforcement() && KalturaCriterion::isTagEnable(KalturaCriterion::TAG_ENTITLEMENT_ENTRY) && self::$kuserBlongToMoreThanMaxCategoriesForSearch && !$c->getOffset()) {
         KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_ENTRY);
         $entitlementCrit = clone $c;
         $entitlementCrit->applyFilters();
         KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_ENTRY);
         if ($entitlementCrit->getRecordsCount() < $entitlementCrit->getLimit()) {
             $c = $entitlementCrit;
             $c->setRecordsCount($entitlementCrit->getRecordsCount());
             $skipApplyFilters = true;
             self::$filerResults = true;
         } else {
             self::$filerResults = false;
             //TODO add header that not full search
         }
     }
     return $skipApplyFilters;
 }
开发者ID:DBezemer,项目名称:server,代码行数:20,代码来源:entryPeer.php

示例6: createSelectSql


//.........这里部分代码省略.........
         }
         // add 'em to the queues..
         if ($joinType = $join->getJoinType()) {
             // real join
             if (!$fromClause) {
                 $fromClause[] = $leftTable . $leftTableAlias;
             }
             $joinTables[] = $rightTable . $rightTableAlias;
             $joinClause[] = $join->getJoinType() . ' ' . $rightTable . $rightTableAlias . " ON ({$condition})";
         } else {
             // implicit join, translates to a where
             $fromClause[] = $leftTable . $leftTableAlias;
             $fromClause[] = $rightTable . $rightTableAlias;
             $whereClause[] = $condition;
         }
     }
     // Unique from clause elements
     $fromClause = array_unique($fromClause);
     $fromClause = array_diff($fromClause, array(''));
     // tables should not exist in both the from and join clauses
     if ($joinTables && $fromClause) {
         foreach ($fromClause as $fi => $ftable) {
             if (in_array($ftable, $joinTables)) {
                 unset($fromClause[$fi]);
             }
         }
     }
     // Add the GROUP BY columns
     $groupByClause = $groupBy;
     $having = $criteria->getHaving();
     $havingString = null;
     if ($having !== null) {
         $sb = "";
         $having->appendPsTo($sb, $params);
         $havingString = $sb;
     }
     if (!empty($orderBy)) {
         foreach ($orderBy as $orderByColumn) {
             // Add function expression as-is.
             if (strpos($orderByColumn, '(') !== false) {
                 $orderByClause[] = $orderByColumn;
                 continue;
             }
             // Split orderByColumn (i.e. "table.column DESC")
             $dotPos = strrpos($orderByColumn, '.');
             if ($dotPos !== false) {
                 $tableName = substr($orderByColumn, 0, $dotPos);
                 $columnName = substr($orderByColumn, $dotPos + 1);
             } else {
                 $tableName = '';
                 $columnName = $orderByColumn;
             }
             $spacePos = strpos($columnName, ' ');
             if ($spacePos !== false) {
                 $direction = substr($columnName, $spacePos);
                 $columnName = substr($columnName, 0, $spacePos);
             } else {
                 $direction = '';
             }
             $tableAlias = $tableName;
             if ($aliasTableName = $criteria->getTableForAlias($tableName)) {
                 $tableName = $aliasTableName;
             }
             $columnAlias = $columnName;
             if ($asColumnName = $criteria->getColumnForAs($columnName)) {
                 $columnName = $asColumnName;
             }
             $column = $tableName ? $dbMap->getTable($tableName)->getColumn($columnName) : null;
             if ($criteria->isIgnoreCase() && $column && $column->isText()) {
                 $orderByClause[] = $db->ignoreCaseInOrderBy("{$tableAlias}.{$columnAlias}") . $direction;
                 $selectClause[] = $db->ignoreCaseInOrderBy("{$tableAlias}.{$columnAlias}");
             } else {
                 $orderByClause[] = $orderByColumn;
             }
         }
     }
     if (empty($fromClause) && $criteria->getPrimaryTableName()) {
         $fromClause[] = $criteria->getPrimaryTableName();
     }
     // from / join tables quoten if it is necessary
     if ($db->useQuoteIdentifier()) {
         $fromClause = array_map(array($db, 'quoteIdentifierTable'), $fromClause);
         $joinClause = $joinClause ? $joinClause : array_map(array($db, 'quoteIdentifierTable'), $joinClause);
     }
     // build from-clause
     $from = '';
     if (!empty($joinClause) && count($fromClause) > 1) {
         $from .= implode(" CROSS JOIN ", $fromClause);
     } else {
         $from .= implode(", ", $fromClause);
     }
     $from .= $joinClause ? ' ' . implode(' ', $joinClause) : '';
     // Build the SQL from the arrays we compiled
     $sql = "SELECT " . ($selectModifiers ? implode(" ", $selectModifiers) . " " : "") . implode(", ", $selectClause) . " FROM " . $from . ($whereClause ? " WHERE " . implode(" AND ", $whereClause) : "") . ($groupByClause ? " GROUP BY " . implode(",", $groupByClause) : "") . ($havingString ? " HAVING " . $havingString : "") . ($orderByClause ? " ORDER BY " . implode(",", $orderByClause) : "");
     // APPLY OFFSET & LIMIT to the query.
     if ($criteria->getLimit() || $criteria->getOffset()) {
         $db->applyLimit($sql, $criteria->getOffset(), $criteria->getLimit());
     }
     return $sql;
 }
开发者ID:alexhandzhiev,项目名称:sifact,代码行数:101,代码来源:BasePeer.php

示例7: doCount

 /**
  * Executes a COUNT query using either a simple SQL rewrite or, for more complex queries, a
  * sub-select of the SQL created by createSelectSql() and returns the statement.
  *
  * @param      Criteria $criteria A Criteria.
  * @param      PropelPDO $con A PropelPDO connection to use.
  * @return     PDOStatement The resultset statement.
  * @throws     PropelException
  * @see        createSelectSql()
  */
 public static function doCount(Criteria $criteria, PropelPDO $con = null)
 {
     $dbMap = Propel::getDatabaseMap($criteria->getDbName());
     $db = Propel::getDB($criteria->getDbName());
     if ($con === null) {
         $con = Propel::getConnection($criteria->getDbName(), Propel::CONNECTION_READ);
     }
     $stmt = null;
     if ($criteria->isUseTransaction()) {
         $con->beginTransaction();
     }
     $needsComplexCount = $criteria->getGroupByColumns() || $criteria->getOffset() || $criteria->getLimit() || $criteria->getHaving() || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers());
     try {
         $params = array();
         if ($needsComplexCount) {
             $selectSql = self::createSelectSql($criteria, $params);
             $sql = 'SELECT COUNT(*) FROM (' . $selectSql . ') AS propelmatch4cnt';
         } else {
             // Replace SELECT columns with COUNT(*)
             $criteria->clearSelectColumns()->addSelectColumn('COUNT(*)');
             $sql = self::createSelectSql($criteria, $params);
         }
         $stmt = $con->prepare($sql);
         self::populateStmtValues($stmt, $params, $dbMap, $db);
         $stmt->execute();
         if ($criteria->isUseTransaction()) {
             $con->commit();
         }
     } catch (Exception $e) {
         if ($stmt) {
             $stmt = null;
         }
         // close
         if ($criteria->isUseTransaction()) {
             $con->rollBack();
         }
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException($e);
     }
     return $stmt;
 }
开发者ID:voota,项目名称:voota,代码行数:51,代码来源:VoBasePeer.class.php


注:本文中的Criteria::getOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。