本文整理汇总了PHP中Propel\Runtime\ActiveQuery\ModelCriteria::offset方法的典型用法代码示例。如果您正苦于以下问题:PHP ModelCriteria::offset方法的具体用法?PHP ModelCriteria::offset怎么用?PHP ModelCriteria::offset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\ActiveQuery\ModelCriteria
的用法示例。
在下文中一共展示了ModelCriteria::offset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: searchWithOffset
/**
* @param ModelCriteria $search
*
* @return ObjectCollection
*/
protected function searchWithOffset(ModelCriteria $search)
{
$limit = intval($this->getArgValue('limit'));
if ($limit >= 0) {
$search->limit($limit);
}
$search->offset(intval($this->getArgValue('offset')));
return $search->find();
}
示例2: testOffset
public function testOffset()
{
$c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book');
$c->limit(50);
$c->offset(10);
if ($this->isDb('mysql')) {
$sql = 'SELECT FROM LIMIT 10, 50';
} else {
$sql = 'SELECT FROM LIMIT 50 OFFSET 10';
}
$params = array();
$this->assertCriteriaTranslation($c, $sql, $params, 'offset() adds an OFFSET clause');
}
示例3: mapOptions
/**
* Maps options like limit, offset, order
*
* @param ModelCriteria $query
* @param array $options
*
* @throws FileNotFoundException
*/
public function mapOptions(ModelCriteria $query, $options = array())
{
if (isset($options['limit'])) {
$query->limit($options['limit']);
}
if (isset($options['offset'])) {
$query->offset($options['offset']);
}
if (isset($options['order']) && is_array($options['order'])) {
foreach ($options['order'] as $field => $direction) {
$fieldName = ucfirst($field);
$tableMap = $this->tableMap;
if (false !== ($pos = strpos($field, '.'))) {
$relationName = ucfirst(substr($field, 0, $pos));
$fieldName = ucfirst(substr($field, $pos + 1));
if (!($relation = $this->tableMap->getRelation($relationName))) {
throw new FileNotFoundException(sprintf('Relation `%s` in object `%s` not found', $relationName, $this->getObjectKey()));
}
$tableMap = $relation->getForeignTable();
}
if ($tableMap->hasColumnByPhpName(ucfirst($fieldName))) {
$column = $this->tableMap->getColumnByPhpName(ucfirst($fieldName));
$query->orderBy($column->getName(), $direction);
}
}
}
}