本文整理汇总了PHP中ApiPageSet::getPageTableFields方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiPageSet::getPageTableFields方法的具体用法?PHP ApiPageSet::getPageTableFields怎么用?PHP ApiPageSet::getPageTableFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiPageSet
的用法示例。
在下文中一共展示了ApiPageSet::getPageTableFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @param ApiPageSet $resultPageSet
* @return void
*/
private function run($resultPageSet = null)
{
$params = $this->extractRequestParams();
$prop = array_flip($params['prop']);
$fld_ids = isset($prop['ids']);
$fld_title = isset($prop['title']);
$fld_value = isset($prop['value']);
if ($resultPageSet === null) {
$this->addFields(['page_id']);
$this->addFieldsIf(['page_title', 'page_namespace'], $fld_title);
$this->addFieldsIf('pp_value', $fld_value);
} else {
$this->addFields($resultPageSet->getPageTableFields());
}
$this->addTables(['page_props', 'page']);
$this->addWhere('pp_page=page_id');
$this->addWhereFld('pp_propname', $params['propname']);
$dir = $params['dir'] == 'ascending' ? 'newer' : 'older';
if ($params['continue']) {
$cont = explode('|', $params['continue']);
$this->dieContinueUsageIf(count($cont) != 1);
// Add a WHERE clause
$from = (int) $cont[0];
$this->addWhereRange('pp_page', $dir, $from, null);
}
$sort = $params['dir'] === 'descending' ? ' DESC' : '';
$this->addOption('ORDER BY', 'pp_page' . $sort);
$limit = $params['limit'];
$this->addOption('LIMIT', $limit + 1);
$result = $this->getResult();
$count = 0;
foreach ($this->select(__METHOD__) as $row) {
if (++$count > $limit) {
// We've reached the one extra which shows that there are
// additional pages to be had. Stop here...
$this->setContinueEnumParameter('continue', $row->page_id);
break;
}
if ($resultPageSet === null) {
$vals = [ApiResult::META_TYPE => 'assoc'];
if ($fld_ids) {
$vals['pageid'] = (int) $row->page_id;
}
if ($fld_title) {
$title = Title::makeTitle($row->page_namespace, $row->page_title);
ApiQueryBase::addTitleInfo($vals, $title);
}
if ($fld_value) {
$vals['value'] = $row->pp_value;
}
$fit = $result->addValue(['query', $this->getModuleName()], null, $vals);
if (!$fit) {
$this->setContinueEnumParameter('continue', $row->page_id);
break;
}
} else {
$resultPageSet->processDbRow($row);
}
}
if ($resultPageSet === null) {
$result->addIndexedTagName(['query', $this->getModuleName()], 'page');
}
}