本文整理汇总了PHP中SelectQuery::range方法的典型用法代码示例。如果您正苦于以下问题:PHP SelectQuery::range方法的具体用法?PHP SelectQuery::range怎么用?PHP SelectQuery::range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SelectQuery
的用法示例。
在下文中一共展示了SelectQuery::range方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getQuery
/**
* Get query
*
* @return \SelectQueryInterface $query
*/
public final function getQuery()
{
if (null === $this->query) {
$this->query = $this->buildQuery();
// Apply conditions.
foreach ($this->conditions as $statement => $value) {
$this->applyOperator($this->query, $statement, $value);
}
$limit = $this->getLimit();
if (CursorInterface::LIMIT_NONE !== $limit) {
$this->query->range($this->getOffset(), $limit);
}
}
return $this->query;
}
示例2: finishQuery
/**
* Finishes the query.
*
* Adds tags, metaData, range and returns the requested list or count.
*
* @param SelectQuery $select_query
* A SelectQuery which has entity_type, entity_id, revision_id and bundle
* fields added.
* @param $id_key
* Which field's values to use as the returned array keys.
*
* @return
* See EntityFieldQuery::execute().
*/
function finishQuery($select_query, $id_key = 'entity_id')
{
foreach ($this->tags as $tag) {
$select_query->addTag($tag);
}
foreach ($this->metaData as $key => $object) {
$select_query->addMetaData($key, $object);
}
$select_query->addMetaData('entity_field_query', $this);
if ($this->range) {
$select_query->range($this->range['start'], $this->range['length']);
}
if ($this->count) {
return $select_query->countQuery()->execute()->fetchField();
}
$return = array();
foreach ($this->fields as $key => $field) {
if ('field_sql_storage' == $field['storage']['type']) {
foreach ($select_query->conditions() as $condition) {
if (is_array($condition) && array_key_exists('field', $condition) && strpos($condition['field'], 'field_data_' . $field['field_name'] . $key . '.') === 0) {
list($table_alias, $column) = explode('.', $condition['field']);
$select_query->addField($table_alias, $column, $field['field_name']);
break;
}
}
}
}
$this->orderedResults = array();
foreach ($select_query->execute() as $partial_entity) {
$bundle = isset($partial_entity->bundle) ? $partial_entity->bundle : NULL;
$entity = entity_create_stub_entity($partial_entity->entity_type, array($partial_entity->entity_id, $partial_entity->revision_id, $bundle));
$return[$partial_entity->entity_type][$partial_entity->{$id_key}] = $entity;
$this->orderedResults[] = $partial_entity;
}
return $return;
}
示例3: queryForListPagination
/**
* Set correct page (i.e. range) for the query for list.
*
* Determine the page that should be seen. Page 1, is actually offset 0 in the
* query range.
*
* @param \SelectQuery $query
* The query object.
*
* @throws BadRequestException
*
* @see \RestfulEntityBase::getQueryForList
*/
protected function queryForListPagination(\SelectQuery $query)
{
list($range, $offset) = $this->parseRequestForListPagination();
$query->range($range, $offset);
}
示例4: setLimit
public function setLimit($limit)
{
$this->selectQuery->range(0, $limit);
}