public function modifyQuery(DpleQuery &$query) { $dbr = $query->getDbr(); $tableName = $dbr->tableName('revision'); /** Add condition based on @ref $createdby_. */ if ($this->createdby_) { $table = "{$tableName} AS rev_c"; $query->addTables($table); $cond = $this->buildIn($this->createdby_); $query->addJoinCond($table, 'INNER JOIN', array('page_id = rev_c.rev_page', 'rev_c.rev_parent_id = 0')); $query->addConds("rev_c.rev_user {$cond}"); } /** Add condition based on @ref $notCreatedby_. */ if ($this->notCreatedby_) { $table = "{$tableName} AS rev_nc"; $query->addTables($table); $cond = 'NOT' . $this->buildIn($this->notCreatedby_); $query->addJoinCond($table, 'INNER JOIN', array('page_id = rev_nc.rev_page', 'rev_nc.rev_parent_id = 0')); $query->addConds("rev_nc.rev_user {$cond}"); } /** Add condition based on @ref $lastmodifiedby_. */ if ($this->lastmodifiedby_) { $table = "{$tableName} AS rev_l"; $query->addTables($table); $cond = $this->buildIn($this->lastmodifiedby_); $query->addJoinCond($table, 'INNER JOIN', array('page_latest = rev_l.rev_id')); $query->addConds("rev_l.rev_user {$cond}"); } /** Add condition based on @ref $notLastmodifiedby_. */ if ($this->notLastmodifiedby_) { $table = "{$tableName} AS rev_nl"; $query->addTables($table); $cond = 'NOT' . $this->buildIn($this->notLastmodifiedby_); $query->addJoinCond($table, 'INNER JOIN', array('page_latest = rev_nl.rev_id')); $query->addConds("rev_nl.rev_user {$cond}"); } /** Add condition based on @ref $modifiedby_. */ if ($this->modifiedby_) { $table = "{$tableName} AS rev_m"; $query->addTables($table); $cond = $this->buildIn($this->modifiedby_); $query->addJoinCond($table, 'INNER JOIN', array('page_id = rev_m.rev_page')); $query->addConds("rev_m.rev_user {$cond}"); $query->setOption('DISTINCT'); } /** Add condition based on @ref $notModifiedby_. */ if ($this->notModifiedby_) { $table = "{$tableName} AS rev_nm"; $query->addTables($table); $cond = $this->buildIn($this->notModifiedby_); $query->addJoinCond($table, 'LEFT OUTER JOIN', array('page_id = rev_nm.rev_page', "rev_nm.rev_user {$cond}")); $query->addConds(array('rev_nm.rev_page' => null)); $query->setOption('DISTINCT'); } }
/** * @brief Modify a given query. * * Add table aliases `{$tableAlias_}1, {$tableAlias_}2, ...` to * DpleQuery::$tables_. * * @param DpleQuery $query Query object. */ public function modifyQuery(DpleQuery &$query) { $dbr = $query->getDbr(); $tableName = $dbr->tableName($this->tableName_); $n = 1; /** Add conditions based on @ref $linkedTitles_. */ for ($i = 0; $i < $this->linkedCount_; $i++) { $table = "{$tableName} AS {$this->tableAlias_}{$n}"; $query->addTables($table); $query->addJoinCond($table, 'INNER JOIN', $this->transformJoinConds_($dbr, $n, $this->linkedTitles_[$i])); $n++; } /** Add conditions based on @ref $notLinkedTitles_. */ for ($i = 0; $i < $this->notLinkedCount_; $i++) { $table = "{$tableName} AS {$this->tableAlias_}{$n}"; $query->addTables($table); $query->addJoinCond($table, 'LEFT OUTER JOIN', $this->transformJoinConds_($dbr, $n, $this->notLinkedTitles_[$i])); $query->addConds(array("{$this->tableAlias_}{$n}.{$this->tableColumn_}" => null)); $n++; } }