本文整理汇总了PHP中IDatabase::select方法的典型用法代码示例。如果您正苦于以下问题:PHP IDatabase::select方法的具体用法?PHP IDatabase::select怎么用?PHP IDatabase::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase::select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doQuery
/**
* @param IDatabase $db
* @return mixed
*/
public function doQuery($db)
{
$ids = array_map('intval', $this->ids);
$live = $db->select(array('revision', 'page', 'user'), array_merge(Revision::selectFields(), Revision::selectUserFields()), array('rev_page' => $this->title->getArticleID(), 'rev_id' => $ids), __METHOD__, array('ORDER BY' => 'rev_id DESC'), array('page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond()));
if ($live->numRows() >= count($ids)) {
// All requested revisions are live, keeps things simple!
return $live;
}
// Check if any requested revisions are available fully deleted.
$archived = $db->select(array('archive'), Revision::selectArchiveFields(), array('ar_rev_id' => $ids), __METHOD__, array('ORDER BY' => 'ar_rev_id DESC'));
if ($archived->numRows() == 0) {
return $live;
} elseif ($live->numRows() == 0) {
return $archived;
} else {
// Combine the two! Whee
$rows = array();
foreach ($live as $row) {
$rows[$row->rev_id] = $row;
}
foreach ($archived as $row) {
$rows[$row->ar_rev_id] = $row;
}
krsort($rows);
return new FakeResultWrapper(array_values($rows));
}
}
示例2: doQuery
/**
* @param IDatabase $db
* @return mixed
*/
public function doQuery($db)
{
$ids = array_map('intval', $this->ids);
$queryInfo = ['tables' => ['revision', 'user'], 'fields' => array_merge(Revision::selectFields(), Revision::selectUserFields()), 'conds' => ['rev_page' => $this->title->getArticleID(), 'rev_id' => $ids], 'options' => ['ORDER BY' => 'rev_id DESC'], 'join_conds' => ['page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond()]];
ChangeTags::modifyDisplayQuery($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], $queryInfo['join_conds'], $queryInfo['options'], '');
$live = $db->select($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], __METHOD__, $queryInfo['options'], $queryInfo['join_conds']);
if ($live->numRows() >= count($ids)) {
// All requested revisions are live, keeps things simple!
return $live;
}
$archiveQueryInfo = ['tables' => ['archive'], 'fields' => Revision::selectArchiveFields(), 'conds' => ['ar_rev_id' => $ids], 'options' => ['ORDER BY' => 'ar_rev_id DESC'], 'join_conds' => []];
ChangeTags::modifyDisplayQuery($archiveQueryInfo['tables'], $archiveQueryInfo['fields'], $archiveQueryInfo['conds'], $archiveQueryInfo['join_conds'], $archiveQueryInfo['options'], '');
// Check if any requested revisions are available fully deleted.
$archived = $db->select($archiveQueryInfo['tables'], $archiveQueryInfo['fields'], $archiveQueryInfo['conds'], __METHOD__, $archiveQueryInfo['options'], $archiveQueryInfo['join_conds']);
if ($archived->numRows() == 0) {
return $live;
} elseif ($live->numRows() == 0) {
return $archived;
} else {
// Combine the two! Whee
$rows = [];
foreach ($live as $row) {
$rows[$row->rev_id] = $row;
}
foreach ($archived as $row) {
$rows[$row->ar_rev_id] = $row;
}
krsort($rows);
return new FakeResultWrapper(array_values($rows));
}
}
示例3: doQuery
/**
* @param IDatabase $db
* @return mixed
*/
public function doQuery($db)
{
$ids = array_map('intval', $this->ids);
$queryInfo = array('tables' => array('revision', 'user'), 'fields' => array_merge(Revision::selectFields(), Revision::selectUserFields()), 'conds' => array('rev_page' => $this->title->getArticleID(), 'rev_id' => $ids), 'options' => array('ORDER BY' => 'rev_id DESC'), 'join_conds' => array('page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond()));
ChangeTags::modifyDisplayQuery($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], $queryInfo['join_conds'], $queryInfo['options'], '');
return $db->select($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], __METHOD__, $queryInfo['options'], $queryInfo['join_conds']);
}
示例4: doQuery
/**
* @param IDatabase $db
* @return mixed
*/
public function doQuery($db)
{
$archiveNames = array();
foreach ($this->ids as $timestamp) {
$archiveNames[] = $timestamp . '!' . $this->title->getDBkey();
}
return $db->select('oldimage', OldLocalFile::selectFields(), array('oi_name' => $this->title->getDBkey(), 'oi_archive_name' => $archiveNames), __METHOD__, array('ORDER BY' => 'oi_timestamp DESC'));
}
示例5: doQuery
/**
* @param IDatabase $db
* @return mixed
*/
public function doQuery($db)
{
$timestamps = array();
foreach ($this->ids as $id) {
$timestamps[] = $db->timestamp($id);
}
return $db->select('archive', Revision::selectArchiveFields(), array('ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey(), 'ar_timestamp' => $timestamps), __METHOD__, array('ORDER BY' => 'ar_timestamp DESC'));
}
示例6: next
/**
* Fetch the next set of rows from the database.
*/
public function next()
{
$res = $this->db->select($this->table, $this->fetchColumns, $this->buildConditions(), __METHOD__, ['LIMIT' => $this->batchSize, 'ORDER BY' => $this->orderBy], $this->joinConditions);
// The iterator is converted to an array because in addition to
// returning it in self::current() we need to use the end value
// in self::buildConditions()
$this->current = iterator_to_array($res);
$this->key++;
}
示例7: doQuery
/**
* @param IDatabase $db
* @return mixed
*/
public function doQuery($db)
{
$ids = array_map('intval', $this->ids);
$queryInfo = DatabaseLogEntry::getSelectQueryData();
$queryInfo['conds'] += array('log_id' => $ids);
$queryInfo['options'] += array('ORDER BY' => 'log_id DESC');
ChangeTags::modifyDisplayQuery($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], $queryInfo['join_conds'], $queryInfo['options'], '');
return $db->select($queryInfo['tables'], $queryInfo['fields'], $queryInfo['conds'], __METHOD__, $queryInfo['options'], $queryInfo['join_conds']);
}
示例8: doQuery
/**
* @param IDatabase $db
* @return mixed
*/
public function doQuery($db)
{
$timestamps = [];
foreach ($this->ids as $id) {
$timestamps[] = $db->timestamp($id);
}
$tables = ['archive'];
$fields = Revision::selectArchiveFields();
$conds = ['ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey(), 'ar_timestamp' => $timestamps];
$join_conds = [];
$options = ['ORDER BY' => 'ar_timestamp DESC'];
ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $options, '');
return $db->select($tables, $fields, $conds, __METHOD__, $options, $join_conds);
}
示例9: doQuery
/**
* @param IDatabase $db
* @return mixed
*/
public function doQuery($db)
{
$conds = ['rev_page' => $this->title->getArticleID()];
if ($this->ids !== null) {
$conds['rev_id'] = array_map('intval', $this->ids);
}
return $db->select(['revision', 'page', 'user'], array_merge(Revision::selectFields(), Revision::selectUserFields()), $conds, __METHOD__, ['ORDER BY' => 'rev_id DESC'], ['page' => Revision::pageJoinCond(), 'user' => Revision::userJoinCond()]);
}
示例10: doBatchPushInternal
/**
* This function should *not* be called outside of JobQueueDB
*
* @param IDatabase $dbw
* @param IJobSpecification[] $jobs
* @param int $flags
* @param string $method
* @throws DBError
* @return void
*/
public function doBatchPushInternal(IDatabase $dbw, array $jobs, $flags, $method)
{
if (!count($jobs)) {
return;
}
$rowSet = array();
// (sha1 => job) map for jobs that are de-duplicated
$rowList = array();
// list of jobs for jobs that are not de-duplicated
foreach ($jobs as $job) {
$row = $this->insertFields($job);
if ($job->ignoreDuplicates()) {
$rowSet[$row['job_sha1']] = $row;
} else {
$rowList[] = $row;
}
}
if ($flags & self::QOS_ATOMIC) {
$dbw->startAtomic($method);
// wrap all the job additions in one transaction
}
try {
// Strip out any duplicate jobs that are already in the queue...
if (count($rowSet)) {
$res = $dbw->select('job', 'job_sha1', array('job_sha1' => array_keys($rowSet), 'job_token' => ''), $method);
foreach ($res as $row) {
wfDebug("Job with hash '{$row->job_sha1}' is a duplicate.\n");
unset($rowSet[$row->job_sha1]);
// already enqueued
}
}
// Build the full list of job rows to insert
$rows = array_merge($rowList, array_values($rowSet));
// Insert the job rows in chunks to avoid slave lag...
foreach (array_chunk($rows, 50) as $rowBatch) {
$dbw->insert('job', $rowBatch, $method);
}
JobQueue::incrStats('inserts', $this->type, count($rows));
JobQueue::incrStats('dupe_inserts', $this->type, count($rowSet) + count($rowList) - count($rows));
} catch (DBError $e) {
if ($flags & self::QOS_ATOMIC) {
$dbw->rollback($method);
}
throw $e;
}
if ($flags & self::QOS_ATOMIC) {
$dbw->endAtomic($method);
}
return;
}
示例11: doQuery
/**
* @param IDatabase $db
* @return mixed
*/
public function doQuery($db)
{
$ids = array_map('intval', $this->ids);
return $db->select('filearchive', ArchivedFile::selectFields(), array('fa_name' => $this->title->getDBkey(), 'fa_id' => $ids), __METHOD__, array('ORDER BY' => 'fa_id DESC'));
}
示例12: addOlds
/**
* Add the old versions of the image to the batch
* @return array List of archive names from old versions
*/
public function addOlds()
{
$archiveBase = 'archive';
$this->olds = [];
$this->oldCount = 0;
$archiveNames = [];
$result = $this->db->select('oldimage', ['oi_archive_name', 'oi_deleted'], ['oi_name' => $this->oldName], __METHOD__, ['LOCK IN SHARE MODE']);
foreach ($result as $row) {
$archiveNames[] = $row->oi_archive_name;
$oldName = $row->oi_archive_name;
$bits = explode('!', $oldName, 2);
if (count($bits) != 2) {
wfDebug("Old file name missing !: '{$oldName}' \n");
continue;
}
list($timestamp, $filename) = $bits;
if ($this->oldName != $filename) {
wfDebug("Old file name doesn't match: '{$oldName}' \n");
continue;
}
$this->oldCount++;
// Do we want to add those to oldCount?
if ($row->oi_deleted & File::DELETED_FILE) {
continue;
}
$this->olds[] = ["{$archiveBase}/{$this->oldHash}{$oldName}", "{$archiveBase}/{$this->newHash}{$timestamp}!{$this->newName}"];
}
return $archiveNames;
}
示例13: listPages
/**
* @param IDatabase $dbr
* @param string|array $condition
* @return bool|ResultWrapper
*/
protected static function listPages($dbr, $condition)
{
return $dbr->select(['archive'], ['ar_namespace', 'ar_title', 'count' => 'COUNT(*)'], $condition, __METHOD__, ['GROUP BY' => ['ar_namespace', 'ar_title'], 'ORDER BY' => ['ar_namespace', 'ar_title'], 'LIMIT' => 100]);
}
示例14: doQuery
/**
* @param IDatabase $db
* @return mixed
*/
public function doQuery($db)
{
$ids = array_map('intval', $this->ids);
return $db->select('logging', array('log_id', 'log_type', 'log_action', 'log_timestamp', 'log_user', 'log_user_text', 'log_namespace', 'log_title', 'log_page', 'log_comment', 'log_params', 'log_deleted'), array('log_id' => $ids), __METHOD__, array('ORDER BY' => 'log_id DESC'));
}
示例15: listPages
/**
* @param IDatabase $dbr
* @param string|array $condition
* @return bool|ResultWrapper
*/
protected static function listPages($dbr, $condition)
{
return $dbr->select(array('archive'), array('ar_namespace', 'ar_title', 'count' => 'COUNT(*)'), $condition, __METHOD__, array('GROUP BY' => array('ar_namespace', 'ar_title'), 'ORDER BY' => array('ar_namespace', 'ar_title'), 'LIMIT' => 100));
}