Debian Codegraph @

includes/Revision/ArchiveSelectQueryBuilder.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 namespace MediaWiki\Revision;
22
23 use Wikimedia\Rdbms\IReadableDatabase;
24 use Wikimedia\Rdbms\SelectQueryBuilder;
25
26 /**
27 * Help and centralize querying archive table.
28 *
29 * @since 1.41
30 */
31 class ArchiveSelectQueryBuilder extends SelectQueryBuilder {
32
33 /**
34 * @internal use RevisionStore::newSelectQueryBuilder() instead.
35 * @param IReadableDatabase $db
36 */
37 public function __construct( IReadableDatabase $db ) {
38 parent::__construct( $db );
39
40 $this->select( [
41 'ar_id',
42 'ar_page_id',
43 'ar_namespace',
44 'ar_title',
45 'ar_rev_id',
46 'ar_timestamp',
47 'ar_minor_edit',
48 'ar_deleted',
49 'ar_len',
50 'ar_parent_id',
51 'ar_sha1',
52 'ar_actor',
53 'ar_user' => 'archive_actor.actor_user',
54 'ar_user_text' => 'archive_actor.actor_name',
55 ] )
56 ->from( 'archive' )
57 ->join( 'actor', 'archive_actor', 'actor_id=ar_actor' );
58 }
59
60 /**
61 * Join the query with comment table and several fields to allow easier query.
62 *
63 * @return $this
64 */
65 public function joinComment() {
66 $this->fields( [
67 'ar_comment_text' => 'comment_ar_comment.comment_text',
68 'ar_comment_data' => 'comment_ar_comment.comment_data',
69 'ar_comment_cid' => 'comment_ar_comment.comment_id',
70 ] );
71 $this->join( 'comment', "comment_ar_comment", 'comment_ar_comment.comment_id = ar_comment_id' );
72 return $this;
73 }
74 }