• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP DatabaseBase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中DatabaseBase的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseBase类的具体用法?PHP DatabaseBase怎么用?PHP DatabaseBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DatabaseBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: deleteRevs

 /**
  * Delete one or more revisions from the database
  * Do this inside a transaction
  *
  * @param array $id Array of revision id values
  * @param DatabaseBase $dbw DatabaseBase class (needs to be a master)
  */
 private function deleteRevs($id, &$dbw)
 {
     if (!is_array($id)) {
         $id = array($id);
     }
     $dbw->delete('revision', array('rev_id' => $id), __METHOD__);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:14,代码来源:deleteOrphanedRevisions.php


示例2: doQuery

 /**
  * @param DatabaseBase $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']);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:11,代码来源:ChangeTagsRevisionList.php


示例3: convertOptionBatch

 /**
  * @param ResultWrapper $res
  * @param DatabaseBase $dbw
  * @return null|int
  */
 function convertOptionBatch($res, $dbw)
 {
     $id = null;
     foreach ($res as $row) {
         $this->mConversionCount++;
         $insertRows = array();
         foreach (explode("\n", $row->user_options) as $s) {
             $m = array();
             if (!preg_match("/^(.[^=]*)=(.*)\$/", $s, $m)) {
                 continue;
             }
             // MW < 1.16 would save even default values. Filter them out
             // here (as in User) to avoid adding many unnecessary rows.
             $defaultOption = User::getDefaultOption($m[1]);
             if (is_null($defaultOption) || $m[2] != $defaultOption) {
                 $insertRows[] = array('up_user' => $row->user_id, 'up_property' => $m[1], 'up_value' => $m[2]);
             }
         }
         if (count($insertRows)) {
             $dbw->insert('user_properties', $insertRows, __METHOD__, array('IGNORE'));
         }
         $dbw->update('user', array('user_options' => ''), array('user_id' => $row->user_id), __METHOD__);
         $id = $row->user_id;
     }
     return $id;
 }
开发者ID:kolzchut,项目名称:mediawiki-molsa-new,代码行数:31,代码来源:convertUserOptions.php


示例4: updateRevision

 public function updateRevision($columnPrefix, DatabaseBase $dbw, $continue = null)
 {
     $rows = $dbw->select('flow_revision', array('rev_id', 'rev_type'), array('rev_id > ' . $dbw->addQuotes($continue), "{$columnPrefix}_id > 0", "{$columnPrefix}_ip IS NOT NULL"), __METHOD__, array('LIMIT' => $this->mBatchSize, 'ORDER BY' => 'rev_id'));
     $ids = $objs = array();
     foreach ($rows as $row) {
         $id = UUID::create($row->rev_id);
         $type = self::$types[$row->rev_type];
         $om = $this->storage->getStorage($type);
         $obj = $om->get($id);
         if ($obj) {
             $om->merge($obj);
             $ids[] = $row->rev_id;
             $objs[] = $obj;
         } else {
             $this->error(__METHOD__ . ": Failed loading {$type}: " . $id->getAlphadecimal());
         }
     }
     if (!$ids) {
         return null;
     }
     $dbw->update('flow_revision', array("{$columnPrefix}_ip" => null), array('rev_id' => $ids), __METHOD__);
     foreach ($objs as $obj) {
         $this->storage->cachePurge($obj);
     }
     $this->completeCount += count($ids);
     return end($ids);
 }
开发者ID:TarLocesilion,项目名称:mediawiki-extensions-Flow,代码行数:27,代码来源:FlowFixUserIp.php


示例5: refreshBatch

 public function refreshBatch(DatabaseBase $dbr, UUID $continue, $countableActions, UUID $stop)
 {
     $rows = $dbr->select('flow_revision', array('rev_id', 'rev_user_id'), array('rev_id > ' . $dbr->addQuotes($continue->getBinary()), 'rev_id <= ' . $dbr->addQuotes($stop->getBinary()), 'rev_user_id > 0', 'rev_user_wiki' => wfWikiID(), 'rev_change_type' => $countableActions), __METHOD__, array('ORDER BY' => 'rev_id ASC', 'LIMIT' => $this->mBatchSize));
     // end of data
     if (!$rows || $rows->numRows() === 0) {
         return false;
     }
     foreach ($rows as $row) {
         // User::incEditCount only allows for edit count to be increased 1
         // at a time. It'd be better to immediately be able to increase the
         // edit count by the exact number it should be increased with, but
         // I'd rather re-use existing code, especially in a run-once script,
         // where performance is not the most important thing ;)
         $user = User::newFromId($row->rev_user_id);
         $user->incEditCount();
         // save updates so we can print them when the script is done running
         if (!isset($this->updates[$user->getId()])) {
             $this->updates[$user->getId()] = 0;
         }
         $this->updates[$user->getId()]++;
         // set value for next batch to continue at
         $continue = $row->rev_id;
     }
     return UUID::create($continue);
 }
开发者ID:TarLocesilion,项目名称:mediawiki-extensions-Flow,代码行数:25,代码来源:FlowFixEditCount.php


示例6: getSQLCondition

 /**
  * @see SMWDescription::getSQLCondition
  *
  * FIXME: store specific code should be in the store component
  *
  * @since 0.6
  * 
  * @param string $tableName
  * @param array $fieldNames
  * @param DatabaseBase $dbs
  * 
  * @return boolean
  */
 public function getSQLCondition($tableName, array $fieldNames, DatabaseBase $dbs)
 {
     $dataItem = $this->getDataItem();
     // Only execute the query when the description's type is geographical coordinates,
     // the description is valid, and the near comparator is used.
     if ($dataItem instanceof SMWDIGeoCoord) {
         switch ($this->getComparator()) {
             case SMW_CMP_EQ:
                 $comparator = '=';
                 break;
             case SMW_CMP_LEQ:
                 $comparator = '<=';
                 break;
             case SMW_CMP_GEQ:
                 $comparator = '>=';
                 break;
             case SMW_CMP_NEQ:
                 $comparator = '!=';
                 break;
             default:
                 return false;
         }
         $lat = $dbs->addQuotes($dataItem->getLatitude());
         $lon = $dbs->addQuotes($dataItem->getLongitude());
         $conditions = array();
         $conditions[] = "{$tableName}.{$fieldNames['1']} {$comparator} {$lat}";
         $conditions[] = "{$tableName}.{$fieldNames['2']} {$comparator} {$lon}";
         return implode(' AND ', $conditions);
     }
     return false;
 }
开发者ID:hangya,项目名称:SemanticMaps,代码行数:44,代码来源:SM_GeoCoordsValueDescription.php


示例7: updateUserWikiCount

 function updateUserWikiCount(DatabaseBase $db, $userId, $wikiCount)
 {
     $res = $db->update("webmaster_user_accounts", array("wikis_number" => $wikiCount), array("user_id" => $userId));
     if (!$res) {
         throw new Exception("Failed to update User id=" . $userId . " count = " . $wikiCount);
     }
 }
开发者ID:yusufchang,项目名称:app,代码行数:7,代码来源:initial_sync_account.php


示例8: doQuery

 /**
  * @param DatabaseBase $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));
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:31,代码来源:RevDelRevisionList.php


示例9: lockTables

 /**
  * Lock the appropriate tables for the script
  * @param DatabaseBase $db
  * @param string $extraTable The name of any extra tables to lock (eg: text)
  */
 private function lockTables($db, $extraTable = [])
 {
     $tbls = ['page', 'revision', 'redirect'];
     if ($extraTable) {
         $tbls = array_merge($tbls, $extraTable);
     }
     $db->lockTables([], $tbls, __METHOD__, false);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:13,代码来源:orphans.php


示例10: doQuery

 /**
  * @param DatabaseBase $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'));
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:12,代码来源:RevDelArchiveList.php


示例11: doQuery

 /**
  * @param DatabaseBase $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'));
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:12,代码来源:RevDelFileList.php


示例12: doQuery

 /**
  * @param DatabaseBase $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']);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:13,代码来源:ChangeTagsLogList.php


示例13: doGetText

 /**
  * May throw a database error if, say, the server dies during query.
  * @param DatabaseBase $db
  * @param int $id The old_id
  * @return string
  */
 private function doGetText($db, $id)
 {
     $id = intval($id);
     $row = $db->selectRow('text', ['old_text', 'old_flags'], ['old_id' => $id], __METHOD__);
     $text = Revision::getRevisionText($row);
     if ($text === false) {
         return false;
     }
     return $text;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:16,代码来源:fetchText.php


示例14: buildPostInExpr

 public static function buildPostInExpr(\DatabaseBase $db, array $arr)
 {
     $range = '';
     foreach ($arr as $post) {
         if ($range) {
             $range .= ',';
         }
         $range .= $db->addQuotes($post->id->getBin());
     }
     return ' IN(' . $range . ')';
 }
开发者ID:nbdd0121,项目名称:MW-FlowThread,代码行数:11,代码来源:Helper.php


示例15: getAccountsToRemove

 /**
  * Get temp user accounts
  *
  * - check if these accounts are really temp ones
  * - do not remove accounts with password set (122 of them)
  *
  * @param DatabaseBase $db
  * @return int[]
  */
 protected function getAccountsToRemove(DatabaseBase $db)
 {
     $res = $db->select(self::USER_TABLE, ['user_id', 'user_name'], ['user_name ' . $db->buildLike(self::TEMPUSER_PREFIX, $db->anyString()), 'user_password' => ''], __METHOD__);
     $users = [];
     while ($user = $res->fetchObject()) {
         // check if this is really a temp user: "TempUser" + <user ID>
         if ($user->user_name === self::TEMPUSER_PREFIX . $user->user_id) {
             $users[] = intval($user->user_id);
         } else {
             $this->output(sprintf(" > skipped %s (#%d)\n", $user->user_name, $user->user_id));
         }
     }
     return $users;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:23,代码来源:removeTempUser.php


示例16: preprocessResults

 /**
  * Cache page existence for performance
  *
  * @param DatabaseBase $db
  * @param ResultWrapper $res
  */
 function preprocessResults($db, $res)
 {
     $batch = new LinkBatch();
     foreach ($res as $row) {
         $batch->add($row->namespace, $row->title);
         $batch->addObj($this->getRedirectTarget($row));
     }
     $batch->execute();
     // Back to start for display
     if ($res->numRows() > 0) {
         // If there are no rows we get an error seeking.
         $db->dataSeek($res, 0);
     }
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:20,代码来源:SpecialListredirects.php


示例17: doTableCleanup

 /**
  * Perform a cleanup for a set of wikis
  *
  * @param DatabaseBase $db database handler
  * @param string $table name of table to clean up
  * @param string $wiki_id_column table column name to use when querying for wiki ID
  * @param Array $city_ids IDs of wikis to remove from the table
  */
 private function doTableCleanup(DatabaseBase $db, $table, array $city_ids, $wiki_id_column = 'wiki_id')
 {
     $start = microtime(true);
     $db->delete($table, [$wiki_id_column => $city_ids], __METHOD__);
     $rows = $db->affectedRows();
     // just in case MW decides to start a transaction automagically
     $db->commit(__METHOD__);
     Wikia\Logger\WikiaLogger::instance()->info(__METHOD__, ['table' => $table, 'cities' => join(', ', $city_ids), 'count' => count($city_ids), 'took' => round(microtime(true) - $start, 4), 'rows' => $rows]);
     $this->output(sprintf("%s: %s - removed %d rows\n", date('Y-m-d H:i:s'), $table, $rows));
     // throttle delete queries
     if ($rows > 0) {
         sleep(5);
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:22,代码来源:eventsCleanup.php


示例18: buildUpdateCondition

 protected function buildUpdateCondition(DatabaseBase $dbw)
 {
     $rcNew = $dbw->addQuotes(RC_NEW);
     $rcSrcNew = $dbw->addQuotes(RecentChange::SRC_NEW);
     $rcEdit = $dbw->addQuotes(RC_EDIT);
     $rcSrcEdit = $dbw->addQuotes(RecentChange::SRC_EDIT);
     $rcLog = $dbw->addQuotes(RC_LOG);
     $rcSrcLog = $dbw->addQuotes(RecentChange::SRC_LOG);
     $rcExternal = $dbw->addQuotes(RC_EXTERNAL);
     $rcSrcExternal = $dbw->addQuotes(RecentChange::SRC_EXTERNAL);
     return "rc_source = CASE\n\t\t\t\t\tWHEN rc_type = {$rcNew} THEN {$rcSrcNew}\n\t\t\t\t\tWHEN rc_type = {$rcEdit} THEN {$rcSrcEdit}\n\t\t\t\t\tWHEN rc_type = {$rcLog} THEN {$rcSrcLog}\n\t\t\t\t\tWHEN rc_type = {$rcExternal} THEN {$rcSrcExternal}\n\t\t\t\t\tELSE ''\n\t\t\t\tEND";
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:12,代码来源:populateRecentChangesSource.php


示例19: outputResults

 /**
  * Format and output report results using the given information plus
  * OutputPage
  *
  * @param OutputPage $out OutputPage to print to
  * @param Skin $skin User skin to use [unused]
  * @param DatabaseBase $dbr (read) connection to use
  * @param int $res Result pointer
  * @param int $num Number of available result rows
  * @param int $offset Paging offset
  */
 protected function outputResults($out, $skin, $dbr, $res, $num, $offset)
 {
     if ($num > 0) {
         $gallery = new ImageGallery();
         # $res might contain the whole 1,000 rows, so we read up to
         # $num [should update this to use a Pager]
         for ($i = 0; $i < $num && ($row = $dbr->fetchObject($res)); $i++) {
             $namespace = isset($row->namespace) ? $row->namespace : NS_FILE;
             $title = Title::makeTitleSafe($namespace, $row->title);
             if ($title instanceof Title && $title->getNamespace() == NS_FILE) {
                 $gallery->add($title, $this->getCellHtml($row));
             }
         }
         $out->addHTML($gallery->toHtml());
     }
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:27,代码来源:ImageQueryPage.php


示例20: getMasterDB

 /**
  * @return DatabaseBase
  */
 function getMasterDB()
 {
     if (!isset($this->dbConn)) {
         $this->dbConn = DatabaseBase::factory($this->dbType, array('host' => $this->dbServer, 'user' => $this->dbUser, 'password' => $this->dbPassword, 'dbname' => $this->dbName, 'flags' => $this->dbFlags, 'tablePrefix' => $this->tablePrefix));
     }
     return $this->dbConn;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:10,代码来源:ForeignDBRepo.php



注:本文中的DatabaseBase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP DatabaseCompatibilityUtil类代码示例发布时间:2022-05-23
下一篇:
PHP Database类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap