本文整理汇总了PHP中Propel\Runtime\ActiveQuery\Criteria::getOffset方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::getOffset方法的具体用法?PHP Criteria::getOffset怎么用?PHP Criteria::getOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\ActiveQuery\Criteria
的用法示例。
在下文中一共展示了Criteria::getOffset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
}
示例2: 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 accepts Criteria::LOGICAL_OR
* This parameter is deprecated, use _or() instead
*
* @return $this|Criteria The current criteria object
*/
public function mergeWith(Criteria $criteria, $operator = null)
{
// merge limit
$limit = $criteria->getLimit();
if (0 != $limit && -1 === $this->getLimit()) {
$this->limit = $limit;
}
// merge offset
$offset = $criteria->getOffset();
if (0 != $offset && 0 === $this->getOffset()) {
$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 LogicException('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 (Criteria::LOGICAL_OR === $operator) {
$this->_or();
}
$isFirstCondition = true;
foreach ($criteria->getMap() as $key => $criterion) {
if ($isFirstCondition && Criteria::LOGICAL_OR === $this->defaultCombineOperator) {
$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
$having = $criteria->getHaving();
if ($having) {
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 LogicException('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;
}