当前位置: 首页>>代码示例>>PHP>>正文


PHP IDatabase类代码示例

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


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

示例1: initConnection

 protected function initConnection($lockDb, IDatabase $db)
 {
     # Let this transaction see lock rows from other transactions
     $db->query("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;");
     # Do everything in a transaction as it all gets rolled back eventually
     $db->startAtomic(__CLASS__);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:7,代码来源:MySqlLockManager.php

示例2: 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));
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:31,代码来源:RevDelRevisionList.php

示例3: getWeightScale

 protected function getWeightScale($index, IDatabase $conn = null)
 {
     if (!$conn) {
         return 0.0;
     }
     $weight = 1.0;
     if ($this->warmCacheRatio > 0) {
         $res = $conn->query('SHOW STATUS', false);
         $s = $res ? $conn->fetchObject($res) : false;
         if ($s === false) {
             $host = $this->parent->getServerName($index);
             $this->replLogger->error(__METHOD__ . ": could not get status for {$host}");
         } else {
             // http://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html
             if ($s->Innodb_buffer_pool_pages_total > 0) {
                 $ratio = $s->Innodb_buffer_pool_pages_data / $s->Innodb_buffer_pool_pages_total;
             } elseif ($s->Qcache_total_blocks > 0) {
                 $ratio = 1.0 - $s->Qcache_free_blocks / $s->Qcache_total_blocks;
             } else {
                 $ratio = 1.0;
             }
             // Stop caring once $ratio >= $this->warmCacheRatio
             $weight *= min($ratio / $this->warmCacheRatio, 1.0);
         }
     }
     return $weight;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:27,代码来源:LoadMonitorMySQL.php

示例4: 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));
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:35,代码来源:RevDelRevisionList.php

示例5: 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']);
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:11,代码来源:ChangeTagsRevisionList.php

示例6: 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'));
 }
开发者ID:xfstudio,项目名称:mediawiki,代码行数:12,代码来源:RevDelFileList.php

示例7: 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'));
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:12,代码来源:RevDelArchiveList.php

示例8: __construct

 /**
  * @param callable $callback
  * @param string $fname Calling method
  * @param IDatabase|null $dbw Abort if this DB is rolled back [optional] (since 1.28)
  */
 public function __construct(callable $callback, $fname = 'unknown', IDatabase $dbw = null)
 {
     $this->callback = $callback;
     $this->fname = $fname;
     if ($dbw && $dbw->trxLevel()) {
         $dbw->onTransactionResolution([$this, 'cancelOnRollback'], $fname);
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:13,代码来源:MWCallableUpdate.php

示例9: 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']);
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:13,代码来源:ChangeTagsLogList.php

示例10: __construct

 /**
  * @param array $params An associative array with one member:
  *   - connection: An IDatabase connection object
  */
 public function __construct(array $params)
 {
     if (!isset($params['connection'])) {
         throw new InvalidArgumentException("Missing 'connection' argument.");
     }
     $this->db = $params['connection'];
     parent::__construct(['servers' => [['type' => $this->db->getType(), 'host' => $this->db->getServer(), 'dbname' => $this->db->getDBname(), 'load' => 1]], 'trxProfiler' => isset($params['trxProfiler']) ? $params['trxProfiler'] : null, 'srvCache' => isset($params['srvCache']) ? $params['srvCache'] : null, 'wanCache' => isset($params['wanCache']) ? $params['wanCache'] : null]);
     if (isset($params['readOnlyReason'])) {
         $this->db->setLBInfo('readOnlyReason', $params['readOnlyReason']);
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:15,代码来源:LoadBalancerSingle.php

示例11: __construct

 /**
  * @param IDatabase $db
  * @param string $error
  * @param int|string $errno
  * @param string $sql
  * @param string $fname
  */
 function __construct(IDatabase $db, $error, $errno, $sql, $fname)
 {
     if ($db instanceof Database && $db->wasConnectionError($errno)) {
         $message = "A connection error occured. \n" . "Query: {$sql}\n" . "Function: {$fname}\n" . "Error: {$errno} {$error}\n";
     } else {
         $message = "A database query error has occurred. Did you forget to run " . "your application's database schema updater after upgrading? \n" . "Query: {$sql}\n" . "Function: {$fname}\n" . "Error: {$errno} {$error}\n";
     }
     parent::__construct($db, $message);
     $this->error = $error;
     $this->errno = $errno;
     $this->sql = $sql;
     $this->fname = $fname;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:20,代码来源:DBQueryError.php

示例12: 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);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:18,代码来源:RevDelArchiveList.php

示例13: getSearchEngineClass

 /**
  * @param IDatabase $db
  * @return string SearchEngine subclass name
  * @since 1.28
  */
 public static function getSearchEngineClass(IDatabase $db)
 {
     switch ($db->getType()) {
         case 'sqlite':
             return 'SearchSqlite';
         case 'mysql':
             return 'SearchMySQL';
         case 'postgres':
             return 'SearchPostgres';
         case 'mssql':
             return 'SearchMssql';
         case 'oracle':
             return 'SearchOracle';
         default:
             return 'SearchEngineDummy';
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:22,代码来源:SearchEngineFactory.php

示例14: write

 /**
  * @param array $updates Array of arrays each containing two keys, 'primaryKey'
  *  and 'changes'. primaryKey must contain a map of column names to values
  *  sufficient to uniquely identify the row changes must contain a map of column
  *  names to update values to apply to the row.
  */
 public function write(array $updates)
 {
     $this->db->begin();
     foreach ($updates as $update) {
         $this->db->update($this->table, $update['changes'], $update['primaryKey'], __METHOD__);
     }
     $this->db->commit();
     wfWaitForSlaves(false, false, $this->clusterName);
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:15,代码来源:BatchRowWriter.php

示例15: write

 /**
  * @param array $updates Array of arrays each containing two keys, 'primaryKey'
  *  and 'changes'. primaryKey must contain a map of column names to values
  *  sufficient to uniquely identify the row changes must contain a map of column
  *  names to update values to apply to the row.
  */
 public function write(array $updates)
 {
     $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
     $ticket = $lbFactory->getEmptyTransactionTicket(__METHOD__);
     foreach ($updates as $update) {
         $this->db->update($this->table, $update['changes'], $update['primaryKey'], __METHOD__);
     }
     $lbFactory->commitAndWaitForReplication(__METHOD__, $ticket);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:15,代码来源:BatchRowWriter.php


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