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


PHP R::setup方法代码示例

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


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

示例1: startTestSuite

 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $dbAdapter = \R::getDatabaseAdapter();
     if (null == $dbAdapter) {
         \R::setup();
     }
 }
开发者ID:dazmiller,项目名称:red4,代码行数:7,代码来源:RedBeanListener.php

示例2: __construct

 public function __construct()
 {
     require_once 'libs/rb.php';
     if (!R::testConnection()) {
         R::setup('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS);
     }
 }
开发者ID:reminchev,项目名称:SoftUni-Projects,代码行数:7,代码来源:BaseModel.php

示例3: configure_redbean

 public function configure_redbean($c)
 {
     \R::setup('mysql:host=' . $c['host'] . ';dbname=' . $c['name'], $c['user'], $c['pass']);
     if (method_exists('\\R', 'setAutoResolve')) {
         \R::setAutoResolve(true);
     }
 }
开发者ID:StudsPro,项目名称:island-peeps-2.0,代码行数:7,代码来源:DB.php

示例4: saveControle

function saveControle($data)
{
    $success = false;
    R::setup('mysql:host=' . Database::HOST . ';dbname=' . Database::NAME, Database::USERNAME, Database::PASSWORD);
    $controle = R::dispense('controle');
    $controle->date = $data['date'];
    $controle->traitement = $data['traitement'] == "true" ? 1 : 0;
    if ($controle->traitement) {
        $controle->traitement_type = $data['traitement_type'];
    }
    $controle->nourrissement = $data['nourrissement'] == "true" ? 1 : 0;
    if ($controle->nourrissement) {
        $controle->nourrissement_quantite = $data['nourrissement_quantite'];
    }
    $controle->nombre_cadres_couvains = $data['nombre_cadres_couvains'];
    $controle_id = R::store($controle);
    $ruche = R::load('ruche', $data['ruche_id']);
    if ($ruche->id) {
        $ruche->ownControle[] = $controle;
        $saved_ruche_id = R::store($ruche);
        if (isset($controle_id) && isset($saved_ruche_id)) {
            $success = true;
        }
    }
    return $success;
}
开发者ID:leloulight,项目名称:didapi,代码行数:26,代码来源:save_controle.php

示例5: setup

 /**
  * Sets up the database connection.
  * @param $dsn The datasource name. See: <a href="http://nl3.php.net/manual/en/pdo.construct.php">http://nl3.php.net/manual/en/pdo.construct.php</a>
  * @code
  *   "sqlite:database.txt"
  *   "mysql:host=localhost;dbname=oodb"
  *   "pgsql:host=localhost;dbname=oodb"
  * @endcode
  * @param $username The database user's login username.
  * @param $password The database user's login password.
  */
 public static function setup($dsn, $username, $password)
 {
     assert('is_string($dsn) && $dsn != ""');
     assert('$username == null || is_string($username) && $username != ""');
     assert('$password == null || is_string($password)');
     assert('!self::isSetup()');
     try {
         R::setup($dsn, $username, $password);
         R::$redbean->addEventListener("update", new RedBeanBeforeUpdateHintManager(R::$toolbox));
         if (SHOW_QUERY_DATA) {
             Yii::app()->performance->setRedBeanQueryLogger(ZurmoRedBeanPluginQueryLogger::getInstanceAndAttach(R::$adapter));
         }
         if (defined('REDBEAN_DEBUG_TO_FILE') && REDBEAN_DEBUG_TO_FILE) {
             $queryLoggerComponent = Yii::createComponent(array('class' => 'application.core.models.ZurmoRedBeanQueryFileLogger'));
             $queryLoggerComponent->init();
             Yii::app()->setComponent('queryFileLogger', $queryLoggerComponent);
             R::debug(true, Yii::app()->queryFileLogger);
         } else {
             R::debug(defined('REDBEAN_DEBUG') && REDBEAN_DEBUG);
         }
         self::$isSetup = true;
         self::$databaseType = substr($dsn, 0, strpos($dsn, ':'));
     } catch (Exception $e) {
         self::close();
         throw $e;
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:38,代码来源:RedBeanDatabase.php

示例6: __construct

 function __construct()
 {
     $this->maxmind = new \GeoIp2\Database\Reader(DIR_ROOT . '/include/maxmind/GeoLite2-City.mmdb');
     $this->tor = new Tor();
     //Let's connect to the database
     R::setup('pgsql:host=' . DB_HOST . ';port=' . DB_PORT . ';dbname=' . DB_NAME, DB_USER, DB_PASS);
 }
开发者ID:GovCERT-CZ,项目名称:Shockpot-Frontend,代码行数:7,代码来源:ShockpotIP.class.php

示例7: onPreDispatch

 public function onPreDispatch()
 {
     $dbms = isset($this->config['dbms']) ? $this->config['dbms'] : 'mysql';
     if ($dbms == 'sqlite') {
         if (!isset($this->config['database'])) {
             throw new \Empathy\MVC\Exception('sqlite database file not supplied.');
         }
         $db = DOC_ROOT . '/' . $this->config['database'];
         if (!file_exists($db)) {
             throw new \Empathy\MVC\Exception('sqlite database file not found.');
         }
         \R::setup('sqlite:' . $db);
     } else {
         if (!defined('DB_SERVER')) {
             throw new \Empathy\MVC\Exception('Database server is not defined in config.');
         }
         if (!$this->isIP(DB_SERVER)) {
             throw new \Empathy\MVC\Exception('Database server must be an IP address.');
         }
         $dsn = $dbms . ':host=' . DB_SERVER . ';dbname=' . DB_NAME . ';';
         if (defined('DB_PORT') && is_numeric(DB_PORT)) {
             $dsn .= 'port=' . DB_PORT . ';';
         }
         \R::setup($dsn, DB_USER, DB_PASS);
     }
 }
开发者ID:mikejw,项目名称:empathy,代码行数:26,代码来源:Redbean.php

示例8: setup

 public static function setup($db_type = "pgsql", $host = "ec2-54-83-204-228.compute-1.amazonaws.com", $db_name = "d31sdik2uip6li", $username = "yghxnskjzqrpvp", $password = "EFOJeYOjNRTXXEBSbllNee1oqV")
 {
     if (!isset(self::$db)) {
         self::$db = R::setup($db_type . ":host=" . $host . "; dbname=" . $db_name, $username, $password);
         R::freeze();
     }
     return self::$db;
 }
开发者ID:33windowlicker,项目名称:web-lmul-rangers,代码行数:8,代码来源:Database.php

示例9: init_db

 public static function init_db()
 {
     // load database system (redbean)
     require_once "system/libraries/rb.php";
     $connection_string = 'mysql:dbname=' . DB_NAME . ';host=' . DB_HOST;
     R::setup($connection_string, DB_USER, DB_PASSWORD);
     R::debug(true);
 }
开发者ID:nemis,项目名称:piranha,代码行数:8,代码来源:system.php

示例10: __construct

 function __construct()
 {
     R::setup('mysql:host=localhost;dbname=Test', 'root', 'mysqladmin');
     //R::freeze( TRUE );
     //  R::startLogging(); //start logging
     //turns debugging ON
     R::debug(FALSE);
 }
开发者ID:xinerd,项目名称:SP_ROI,代码行数:8,代码来源:crud.php

示例11: prepare

 /**
  * @BeforeSuite
  */
 public static function prepare(SuiteEvent $event)
 {
     // prepare system for test suite
     // before it runs
     $config = json_decode(file_get_contents(__DIR__ . "/../../.config/database.json"));
     R::setup($config->driver . ':host=' . $config->host . ';dbname=' . $config->dbname, $config->user, $config->pass);
     R::nuke();
 }
开发者ID:renomx,项目名称:apistarter,代码行数:11,代码来源:FeatureContext.php

示例12: doInit

 public static function doInit()
 {
     include implode(DIRECTORY_SEPARATOR, [__DIR__, '..', 'library', 'redbean', 'rb.php']);
     $dsn = "mysql:host=" . Config::$dbHost . ";dbname=" . Config::$dbName;
     $username = Config::$dbUser;
     $password = Config::$dbPassword;
     R::setup($dsn, $username, $password, true);
     ReflectionHelper::loadClasses(__DIR__ . DIRECTORY_SEPARATOR . 'Models');
 }
开发者ID:asmdz,项目名称:malgraph,代码行数:9,代码来源:Database.php

示例13: __construct

 function __construct($db, $data_dir)
 {
     R::setup('sqlite:' . $db);
     $this->data_dir = $data_dir;
     $this->authors_dir = $this->data_dir . '/authors';
     if (!file_exists($this->authors_dir)) {
         mkdir($this->authors_dir);
     }
 }
开发者ID:chrispoupart,项目名称:BicBucStriim,代码行数:9,代码来源:data.php

示例14: __construct

 public function __construct()
 {
     //        parent::__construct(DB_TYPE . ':host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS);
     //        R::setup('mysql:host=localhost;dbname=orm', 'root', 'mysqladmin');
     R::setup(DB_TYPE . ':host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS);
     R::freeze(TRUE);
     //R::startLogging(); //start logging
     //        R::debug(TRUE);//turns debugging ON
 }
开发者ID:xinerd,项目名称:SP_ROI,代码行数:9,代码来源:Database.php

示例15: _connect

 static function _connect($db = null)
 {
     if (empty($db)) {
         R::setup();
         // for testing locally or where zero config is possible. Use like this: scraperwiki::_connect('');
     } else {
         R::setup($db);
     }
 }
开发者ID:scottbw,项目名称:ukrlp_1,代码行数:9,代码来源:scraperwiki.php


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