本文整理汇总了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();
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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');
}
示例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);
}
}
示例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
}
示例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);
}
}