7use Wikimedia\Assert\Assert;
32 parent::__construct(
$db );
33 $this->pageStore = $pageStore;
34 $this->
table(
'page' );
35 $this->linkCache = $linkCache;
46 Assert::parameterType( [
'integer',
'array' ], $pageIds,
'$pageIds' );
49 $this->
conds( [
'page_id' => $pageIds ] );
51 $this->
conds(
'0 = 1' );
65 $this->conds( [
'page_namespace' => $namespace ] );
78 $this->whereNamespace( $namespace );
80 $this->db->expr(
'page_title', IExpression::LIKE,
new LikeValue( $prefix, $this->db->anyString() ) )
93 public function whereTitles(
int $namespace, $pageTitles ): self {
94 Assert::parameterType( [
'string',
'array' ], $pageTitles,
'$pageTitles' );
95 $this->conds( [
'page_namespace' => $namespace ] );
96 $this->conds( [
'page_title' => $pageTitles ] );
108 $this->orderBy( [
'page_namespace',
'page_title' ], $dir );
120 $this->orderBy(
'page_id', $dir );
130 $this->fields( $this->pageStore->getSelectFields() );
132 $row = $this->fetchRow();
137 $rec = $this->pageStore->newPageRecordFromRow( $row );
138 if ( $this->linkCache ) {
139 $this->linkCache->addGoodLinkObjFromRow( $rec, $row );
150 $this->fields( $this->pageStore->getSelectFields() );
152 $result = $this->fetchResultSet();
153 foreach ( $result as $row ) {
154 $rec = $this->pageStore->newPageRecordFromRow( $row );
155 if ( $this->linkCache ) {
156 $this->linkCache->addGoodLinkObjFromRow( $rec, $row );
172 foreach ( $this->fetchPageRecords() as $rec ) {
173 $recs[ $rec->getId() ] = $rec;
185 $this->field(
'page_id' );
186 return array_map(
'intval', $this->fetchFieldValues() );
whereTitlePrefix(int $namespace, string $prefix)
Find by provided prefix.
fetchPageRecords()
Fetch PageRecords for the specified query.
wherePageIds( $pageIds)
Find by provided page ids.
whereTitles(int $namespace, $pageTitles)
Find by provided page titles.
fetchPageRecord()
Fetch a single PageRecord that matches specified criteria.
orderByPageId(string $dir=self::SORT_ASC)
Order results by page id.
fetchPageIds()
Returns an array of page ids matching the query.
orderByTitle(string $dir=self::SORT_ASC)
Order results by namespace and title in $direction.
fetchPageRecordArray()
Fetch PageRecords for the specified query as an associative array, using page IDs as array keys.
__construct(IReadableDatabase $db, PageStore $pageStore, ?LinkCache $linkCache=null)
whereNamespace(int $namespace)
Find by provided namespace.