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


PHP DatabaseBase::isOpen方法代码示例

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


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

示例1: rotateDb

 /**
  * Drop the database connection $this->db and try to get a new one.
  *
  * This function tries to get a /different/ connection if this is
  * possible. Hence, (if this is possible) it switches to a different
  * failover upon each call.
  *
  * This function resets $this->lb and closes all connections on it.
  *
  * @throws MWException
  */
 function rotateDb()
 {
     // Cleaning up old connections
     if (isset($this->lb)) {
         $this->lb->closeAll();
         unset($this->lb);
     }
     if ($this->forcedDb !== null) {
         $this->db = $this->forcedDb;
         return;
     }
     if (isset($this->db) && $this->db->isOpen()) {
         throw new MWException('DB is set and has not been closed by the Load Balancer');
     }
     unset($this->db);
     // Trying to set up new connection.
     // We do /not/ retry upon failure, but delegate to encapsulating logic, to avoid
     // individually retrying at different layers of code.
     // 1. The LoadBalancer.
     try {
         $this->lb = wfGetLBFactory()->newMainLB();
     } catch (Exception $e) {
         throw new MWException(__METHOD__ . " rotating DB failed to obtain new load balancer (" . $e->getMessage() . ")");
     }
     // 2. The Connection, through the load balancer.
     try {
         $this->db = $this->lb->getConnection(DB_SLAVE, 'dump');
     } catch (Exception $e) {
         throw new MWException(__METHOD__ . " rotating DB failed to obtain new database (" . $e->getMessage() . ")");
     }
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:42,代码来源:dumpTextPass.php


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