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


PHP R::addDatabase方法代码示例

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


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

示例1: connect

function connect()
{
    $config = \configuration\load();
    if (empty($config['dsn']) || empty($config['user']) || empty($config['password'])) {
        die("Please check the configuration\\database.php file");
    }
    R::addDatabase('db', $config['dsn'], $config['user'], $config['password'], $config['frozen']);
    R::selectDatabase('db');
}
开发者ID:draganescu,项目名称:sibip,代码行数:9,代码来源:configuration.php

示例2: __construct

 /**
  * @param array $db
  * @throws \Exception
  */
 public function __construct($db = [])
 {
     $this->db = $db;
     $this->cache = isset($db['dev']) && $db['dev'] ? true : false;
     foreach ($this->db as $key => $db) {
         if (!isset($db['user']) || !isset($db['pass']) || !isset($db['host']) || !isset($db['db'])) {
             throw new \Exception('Missing arguments for RedBean constructor');
         }
         $db['driver'] == 'sqlite' ? R::addDatabase($key, 'sqlite:/tmp/dbfile.db') : R::addDatabase($key, $db['driver'] . ':host=' . $db['host'] . ';dbname=' . $db['db'], $db['user'], $db['pass']);
     }
 }
开发者ID:jetfirephp,项目名称:db,代码行数:15,代码来源:RedBeanConstructor.php

示例3: init

 protected static function init()
 {
     if (self::$_inited) {
         return;
     }
     $c = static::conf();
     shuffle($c['write']);
     shuffle($c['read']);
     self::$_mcs = $c['write'];
     self::$_scs = array_merge($c['read'], $c['write']);
     R::setup();
     foreach (self::$_mcs as $i => $c) {
         R::addDatabase("write:{$i}", sprintf('mysql:host=%s;port=%d;dbname=%s', $c['host'], $c['port'], $c['dbname']), $c['username'], $c['password']);
     }
     foreach (self::$_scs as $i => $c) {
         R::addDatabase("read:{$i}", sprintf('mysql:host=%s;port=%d;dbname=%s', $c['host'], $c['port'], $c['dbname']), $c['username'], $c['password']);
     }
     self::$_inited = true;
 }
开发者ID:txthinking,项目名称:buggy,代码行数:19,代码来源:DB.php


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