public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { $dbAdapter = \R::getDatabaseAdapter(); if (null == $dbAdapter) { \R::setup(); } }
public function __construct() { require_once 'libs/rb.php'; if (!R::testConnection()) { R::setup('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS); } }
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); } }
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; }
/** * 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; } }
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); }
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); } }
public static function setup($db_type = "pgsql", $host = "ec2-54-83-204-228.compute-1.amazonaws.com", $db_name = "d31sdik2uip6li", $username = "******", $password = "******") { if (!isset(self::$db)) { self::$db = R::setup($db_type . ":host=" . $host . "; dbname=" . $db_name, $username, $password); R::freeze(); } return self::$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); }
function __construct() { R::setup('mysql:host=localhost;dbname=Test', 'root', 'mysqladmin'); //R::freeze( TRUE ); // R::startLogging(); //start logging //turns debugging ON R::debug(FALSE); }
/** * @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(); }
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'); }
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); } }
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 }
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); } }
/** * Connect to database, for more information about redbean, check http://redbeanphp.com/ * @return RedBean_ToolBox */ protected function __connect() { if (!is_object(R::$toolbox)) { R::setup('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD, false); R::freeze(true); R::setStrictTyping(false); //$this->toolbox = RedBean_Setup::kickstart('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASSWORD, false); } return R::$toolbox; }
function __construct() { $file = 'libs/rb.php'; if (file_exists($file)) { require $file; R::setup('sqlite:/data.db'); } else { print_r(new Status('Redbeanphp fil ikke fundet')); } }
public function __construct($request) { // load and setup the Red Bean ORM require_once 'include/RedBeanPHP4_3_1/rb.php'; R::setup('mysql:host=' . JAC_DB_HOST . ';dbname=' . JAC_DB_NAME, JAC_DB_USER, JAC_DB_PASS); R::setAutoResolve(TRUE); // set the uri of current request $this->getSelfUri(); // assign request array $this->request = $request; }
public static function setup() { self::init(); self::$dbh = new PDO('mysql:host=' . self::$server . ';dbname=' . self::$databasename . ';', self::$username, self::$password); self::$dbh->query('SET NAMES utf8'); R::setup(self::$dbh); R::debug(true, 1); R::freeze(true); // self::$logsrv = new SystemlogsService(); self::$queryLogger = R::getDatabaseAdapter()->getDatabase()->getLogger(); }
public function construct() { $configuration = $this->configuration; // Get RedBeanPHP. require_once 'plugins/RedBeanORM/resources/rb.php'; // Setup ReadBeanPHP. if (empty($this->dsn)) { $db_settings = PU_GetDBSettings($configuration); R::setup("mysql:host={$db_settings['host']};dbname={$db_settings['database']}", $db_settings['username'], $db_settings['password'], $configuration['production']); } else { R::setup($this->dsn); } }
public static function connect() { WFELoader::load("core/libs/redbean/rb.php"); WFELoader::load("core/libs/QueryBuilder/QueryBuilder.php"); $host = WFEConfig::get('db::host'); $name = WFEConfig::get('db::name'); $user = WFEConfig::get('db::user'); $password = WFEConfig::get('db::password'); $dbEnabled = WFEConfig::get('db::enabled'); if ($dbEnabled == true) { R::setup('mysql:host=' . $host . '; dbname=' . $name, $user, $password); } }
public function authenticate(Request $request) { \R::setup('mysql:host=localhost;dbname=gazingle', 'root', ''); $redis = Redis::connection(); $user = \R::getRow('select * from users where email = "' . $request->email . '"'); //return $user; if ($request->password === \Crypt::decrypt($user['password'])) { \Auth::loginUsingId($user['id']); $redis->set(\Crypt::encrypt($request->email), $user['id']); return $redis->get($request->email); } return response('Unauthorized.', 401); }
function __construct() { // Include database configuration include APPPATH . '/config/database.php'; // Get Redbean include APPPATH . '/third_party/RedBean/rb.php'; // Database data $host = $db[$active_group]['hostname']; $user = $db[$active_group]['username']; $pass = $db[$active_group]['password']; $db = $db[$active_group]['database']; // Setup DB connection R::setup("mysql:host={$host};dbname={$db}", $user, $pass); }
function __construct() { // Include database configuration include APPPATH . 'config' . (ENVIRONMENT == 'testing' ? '/' . ENVIRONMENT : '') . '/database.php'; // Get Redbean include APPPATH . 'third_party/rb.phar'; // Database data $host = $db[$active_group]['hostname']; $user = $db[$active_group]['username']; $pass = $db[$active_group]['password']; $db = $db[$active_group]['database']; // Setup DB connection R::setup("mysql:host={$host};dbname={$db}", $user, $pass); }
public function __construct() { if (!\R::getDatabaseAdapter()) { $dbConfig = (require_once __DIR__ . '/cnf.php'); static::$_host = $dbConfig['host']; static::$_dbname = $dbConfig['dbname']; static::$_user = $dbConfig['user']; static::$_password = $dbConfig['password']; \R::setup('mysql:host=' . static::$_host . ';dbname=' . static::$_dbname, static::$_user, static::$_password, true); //for both mysql or mariaDB } $this->_redbeans = \R::getToolBox()->getRedBean(); $this->_rbToolbox = \R::getToolBox(); }
/** * @param ServiceLocatorInterface $serviceLocator * @return R */ public function createService(ServiceLocatorInterface $serviceLocator) { $rjhRedbeanService = new R(); $config = $serviceLocator->get('config'); $rjhRedbeanConfig = $config['rjhredbean']; $connection = $rjhRedbeanConfig['connection']; $dsn = $connection['dsn']; $user = $connection['user']; $password = $connection['password']; $rjhRedbeanService->setup($dsn, $user, $password); $rjhRedbeanService->freeze($rjhRedbeanConfig['freeze']); $rjhRedbeanService->debug($rjhRedbeanConfig['debug']); return $rjhRedbeanService; }
/** * Create a new connection from the database.php cofig. * * @return void */ public static function setup() { // get all connections $connections = Config::get('database.connections'); // get the current connection $default = Config::get('database.default'); // form the DSN from the current connection $dsn = $connections[$default]['driver'] . ':host=' . $connections[$default]['host'] . ';dbname=' . $connections[$default]['database']; // auth details $user = $connections[$default]['username']; $pass = $connections[$default]['password']; R::setup($dsn, $user, $pass); //print_r($connections[$default]); }
public static function setupRedBean() { try { if (!self::$_redBeanInitialized) { self::$_redBeanInitialized = true; R::setup(Config::get('database_dsn'), Config::get('database_user'), Config::get('database_password')); R::freeze(true); R::exec('SET NAMES utf8'); define('REDBEAN_MODEL_PREFIX', '\\Sop\\Model\\'); } } catch (\Exception $e) { \Sop\Log::error(__FILE__, __LINE__, 'Failed to setup database connection'); throw $e; } }
/** * setup a Redbean instance from CosCMS */ public static function connect() { static $connected = null; if (!$connected) { $url = conf::getMainIni('url'); $username = conf::getMainIni('username'); $password = conf::getMainIni('password'); R::setup($url, $username, $password); $freeze = conf::getMainIni('rb_freeze'); if ($freeze == 1) { R::freeze(true); } $connected = true; } }
public function boot(Application $app) { $dsn = null; switch ($app['db.options']['driver']) { case 'pdo_mysql': $dsn = sprintf('mysql:host=%s;dbname=%s;charset=%s', $app['db.options']['host'], $app['db.options']['dbname'], $app['db.options']['charset']); break; case 'pdo_sqlite': $dsn = sprintf('sqlite:%s', $app['db.options']['path']); break; default: throw new \Exception('目前只支持 pdo_mysql 和 pdo_sqlite '); } \R::setup($dsn, $app['db.options']['user'], $app['db.options']['password']); }