本文整理汇总了PHP中PhabricatorCursorPagedPolicyAwareQuery::buildPagingClause方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorCursorPagedPolicyAwareQuery::buildPagingClause方法的具体用法?PHP PhabricatorCursorPagedPolicyAwareQuery::buildPagingClause怎么用?PHP PhabricatorCursorPagedPolicyAwareQuery::buildPagingClause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorCursorPagedPolicyAwareQuery
的用法示例。
在下文中一共展示了PhabricatorCursorPagedPolicyAwareQuery::buildPagingClause方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildPagingClause
protected function buildPagingClause(AphrontDatabaseConnection $conn_r)
{
$default = parent::buildPagingClause($conn_r);
$before_id = $this->getBeforeID();
$after_id = $this->getAfterID();
if (!$before_id && !$after_id) {
return $default;
}
$cursor_id = nonempty($before_id, $after_id);
$cursor_parts = explode('.', $cursor_id, 2);
$task_id = $cursor_parts[0];
$group_id = idx($cursor_parts, 1);
$cursor = $this->loadCursorObject($task_id);
if (!$cursor) {
return null;
}
$columns = array();
switch ($this->groupBy) {
case self::GROUP_NONE:
break;
case self::GROUP_PRIORITY:
$columns[] = array('name' => 'task.priority', 'value' => (int) $group_id, 'type' => 'int');
break;
case self::GROUP_OWNER:
$columns[] = array('name' => '(task.ownerOrdering IS NULL)', 'value' => (int) (strlen($group_id) ? 0 : 1), 'type' => 'int');
if ($group_id) {
$paging_users = id(new PhabricatorPeopleQuery())->setViewer($this->getViewer())->withPHIDs(array($group_id))->execute();
if (!$paging_users) {
return null;
}
$columns[] = array('name' => 'task.ownerOrdering', 'value' => head($paging_users)->getUsername(), 'type' => 'string', 'reverse' => true);
}
break;
case self::GROUP_STATUS:
$columns[] = array('name' => 'task.status', 'value' => $group_id, 'type' => 'string');
break;
case self::GROUP_PROJECT:
$columns[] = array('name' => '(projectGroupName.indexedObjectName IS NULL)', 'value' => (int) (strlen($group_id) ? 0 : 1), 'type' => 'int');
if ($group_id) {
$paging_projects = id(new PhabricatorProjectQuery())->setViewer($this->getViewer())->withPHIDs(array($group_id))->execute();
if (!$paging_projects) {
return null;
}
$columns[] = array('name' => 'projectGroupName.indexedObjectName', 'value' => head($paging_projects)->getName(), 'type' => 'string', 'reverse' => true);
}
break;
default:
throw new Exception("Unknown group query '{$this->groupBy}'!");
}
$app_columns = $this->buildApplicationSearchPagination($conn_r, $cursor);
if ($app_columns) {
$columns = array_merge($columns, $app_columns);
$columns[] = array('name' => 'task.id', 'value' => (int) $cursor->getID(), 'type' => 'int');
} else {
switch ($this->orderBy) {
case self::ORDER_PRIORITY:
if ($this->groupBy != self::GROUP_PRIORITY) {
$columns[] = array('name' => 'task.priority', 'value' => (int) $cursor->getPriority(), 'type' => 'int');
}
$columns[] = array('name' => 'task.subpriority', 'value' => (int) $cursor->getSubpriority(), 'type' => 'int', 'reverse' => true);
$columns[] = array('name' => 'task.dateModified', 'value' => (int) $cursor->getDateModified(), 'type' => 'int');
break;
case self::ORDER_CREATED:
$columns[] = array('name' => 'task.id', 'value' => (int) $cursor->getID(), 'type' => 'int');
break;
case self::ORDER_MODIFIED:
$columns[] = array('name' => 'task.dateModified', 'value' => (int) $cursor->getDateModified(), 'type' => 'int');
break;
case self::ORDER_TITLE:
$columns[] = array('name' => 'task.title', 'value' => $cursor->getTitle(), 'type' => 'string');
$columns[] = array('name' => 'task.id', 'value' => $cursor->getID(), 'type' => 'int');
break;
default:
throw new Exception("Unknown order query '{$this->orderBy}'!");
}
}
return $this->buildPagingClauseFromMultipleColumns($conn_r, $columns, array('reversed' => (bool) ($before_id xor $this->getReversePaging())));
}
示例2: buildPagingClause
protected function buildPagingClause(AphrontDatabaseConnection $conn_r)
{
$default = parent::buildPagingClause($conn_r);
$before_id = $this->getBeforeID();
$after_id = $this->getAfterID();
if (!$before_id && !$after_id) {
return $default;
}
if ($before_id) {
$cursor = $this->loadCursorObject($before_id);
} else {
$cursor = $this->loadCursorObject($after_id);
}
if (!$cursor) {
return null;
}
$columns = array();
switch ($this->order) {
case self::ORDER_CREATED:
return $default;
case self::ORDER_MODIFIED:
$columns[] = array('name' => 'r.dateModified', 'value' => $cursor->getDateModified(), 'type' => 'int');
break;
case self::ORDER_PATH_MODIFIED:
$columns[] = array('name' => 'p.epoch', 'value' => $cursor->getDateCreated(), 'type' => 'int');
break;
}
$columns[] = array('name' => 'r.id', 'value' => $cursor->getID(), 'type' => 'int');
return $this->buildPagingClauseFromMultipleColumns($conn_r, $columns, array('reversed' => (bool) ($before_id xor $this->getReversePaging())));
}
示例3: buildPagingClause
protected function buildPagingClause(AphrontDatabaseConnection $conn_r)
{
$default = parent::buildPagingClause($conn_r);
$before_id = $this->getBeforeID();
$after_id = $this->getAfterID();
if (!$before_id && !$after_id) {
return $default;
}
$order = $this->order;
if ($order == self::ORDER_CREATED) {
return $default;
}
if ($before_id) {
$cursor = $this->loadCursorObject($before_id);
} else {
$cursor = $this->loadCursorObject($after_id);
}
if (!$cursor) {
return null;
}
$id_column = array('name' => 'r.id', 'type' => 'int', 'value' => $cursor->getID());
$columns = array();
switch ($order) {
case self::ORDER_COMMITTED:
$commit = $cursor->getMostRecentCommit();
if (!$commit) {
return null;
}
$columns[] = array('name' => 's.epoch', 'type' => 'int', 'value' => $commit->getEpoch());
$columns[] = $id_column;
break;
case self::ORDER_CALLSIGN:
$columns[] = array('name' => 'r.callsign', 'type' => 'string', 'value' => $cursor->getCallsign(), 'reverse' => true);
break;
case self::ORDER_NAME:
$columns[] = array('name' => 'r.name', 'type' => 'string', 'value' => $cursor->getName(), 'reverse' => true);
$columns[] = $id_column;
break;
default:
throw new Exception("Unknown order '{$order}'!");
}
return $this->buildPagingClauseFromMultipleColumns($conn_r, $columns, array('reversed' => (bool) $before_id));
}