當前位置: 首頁>>代碼示例>>PHP>>正文


PHP R::setup方法代碼示例

本文整理匯總了PHP中RedBeanPHP\R::setup方法的典型用法代碼示例。如果您正苦於以下問題:PHP R::setup方法的具體用法?PHP R::setup怎麽用?PHP R::setup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RedBeanPHP\R的用法示例。


在下文中一共展示了R::setup方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setupMySql

 public function setupMySql($host, $name, $user, $password)
 {
     $this->dbHost = $host;
     $this->dbName = $name;
     $this->dbUser = $user;
     $this->dbPassword = $password;
     R::setup('mysql:host=' . $host . ';dbname=' . $name, $user, $password);
     return $this;
 }
開發者ID:Koohiisan,項目名稱:Enpowi,代碼行數:9,代碼來源:Config.php

示例2: run

 public function run()
 {
     global $slim;
     $view = new \Slim\Views\Smarty();
     $view->parserExtensions = ['vendor/slim/views/SmartyPlugins'];
     $this->slim = $slim = new Slim(['view' => $view, 'templates.path' => 'views']);
     $this->slim->setName('um');
     R::setup('mysql:host=localhost;dbname=um', 'root', '');
     // add middleware
     $this->addMiddleware(new AuthMiddleware());
     $this->route = new Route($this->slim);
     $this->route->run();
     $this->slim->run();
 }
開發者ID:nuiz,項目名稱:um,代碼行數:14,代碼來源:Main.php

示例3: setupBeforeClass

 public static function setupBeforeClass()
 {
     try {
         R::setup('sqlite:tests.db');
     } catch (Exception $ex) {
     }
 }
開發者ID:kiswa,項目名稱:SMPLog,代碼行數:7,代碼來源:PostsTest.php

示例4: DBSetup

 public static function DBSetup()
 {
     $config = \Config::getSection("DB1");
     if (!self::$CONNECTED) {
         R::setup('mysql:host=localhost;dbname=' . $config['dbname'], $config['username'], $config['password']);
         self::$CONNECTED = true;
     }
 }
開發者ID:rx-projects,項目名稱:comicasa,代碼行數:8,代碼來源:Service.php

示例5: __invoke

 /**
  * Create the controller action service
  *
  * @param ContainerInterface $container
  * @return \Ultradata\Home\Controller\HomePageAction
  */
 public function __invoke(ContainerInterface $container)
 {
     // set up database connection
     $config = $this->getConfig($container);
     \RedBeanPHP\R::setup(sprintf("mysql:host=%s;dbname=%s", $config['host'], $config['dname']), $config['username'], $config['password']);
     $router = $container->get('Zend\\Expressive\\Router\\RouterInterface');
     $template = $container->has('Zend\\Expressive\\Template\\TemplateRendererInterface') ? $container->get('Zend\\Expressive\\Template\\TemplateRendererInterface') : null;
     $controller = new Controller($router, $template);
     return $controller;
 }
開發者ID:rlandas,項目名稱:UltradataHome,代碼行數:16,代碼來源:HomePageActionFactory.php

示例6: register

 public function register(Container $app)
 {
     $app['db'] = function () use($app) {
         $options = array('dsn' => null, 'username' => null, 'password' => null, 'frozen' => false);
         if (isset($app['db.options'])) {
             $options = array_replace($options, $app['db.options']);
         }
         R::setup($options['dsn'], $options['username'], $options['password'], $options['frozen']);
     };
 }
開發者ID:ivoba,項目名稱:redbean-service-provider,代碼行數:10,代碼來源:RedBeanServiceProvider.php

示例7: register

 public function register(Container $c)
 {
     $settings = $c["settings"];
     $options = ['dsn' => null, 'username' => null, 'password' => null, 'frozen' => false];
     if (isset($settings["redbean.setup"])) {
         $options = array_merge($options, $settings["redbean.setup"]);
     }
     $c["redbean"] = R::setup($options["dns"], $options["username"], $options["password"], $options["frozen"]);
     $c["redbean.helper"] = new \CodePasha\RedBean\Support\RedBeanHelper();
     R::getRedBean()->setBeanHelper($c["redbean.helper"]);
     R::setAutoResolve(true);
 }
開發者ID:MhmdLab,項目名稱:redbean-slim,代碼行數:12,代碼來源:RedBeanServiceProvider.php

示例8: connectExisting

 /**
  * Connect to existing database handle with RedBeans
  */
 public static function connectExisting()
 {
     static $connected = null;
     if (!$connected) {
         R::setup(connect::$dbh);
         $connected = true;
     }
     $freeze = conf::getMainIni('rb_freeze');
     if ($freeze == 1) {
         R::freeze(true);
     }
 }
開發者ID:diversen,項目名稱:simple-php-classes,代碼行數:15,代碼來源:rb.php

示例9: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     //Get DB configs from app/config/database.php
     $default = Config::get('database.default');
     $connections = Config::get('database.connections');
     $db_host = $connections[$default]['host'];
     $db_user = $connections[$default]['username'];
     $db_pass = $connections[$default]['password'];
     $db_name = $connections[$default]['database'];
     $db_driver = $connections[$default]['driver'];
     //Run the R::setup command based on db_type
     if ($default != 'sqlite') {
         $conn_string = $db_driver . ':host=' . $db_host . ';dbname=' . $db_name;
     } else {
         $conn_string = $db_driver . ':' . $db_name;
     }
     R::setup($conn_string, $db_user, $db_pass);
 }
開發者ID:ycms,項目名稱:redbean-laravel5,代碼行數:23,代碼來源:RedbeanLaravel4ServiceProvider.php

示例10: run

 public function run()
 {
     global $slim;
     $view = new \Slim\Views\Smarty();
     $view->parserExtensions = ['vendor/slim/views/SmartyPlugins'];
     $this->slim = $slim = new Slim(['view' => $view, 'templates.path' => 'views']);
     $this->slim->setName('um');
     R::setup('mysql:host=localhost;dbname=lighting_durag', 'root', '');
     // R::setup('mysql:host=localhost;dbname=lighting_durag', 'root', 'mysql@umi');
     R::ext('xdispense', function ($type) {
         return R::getRedBean()->dispense($type);
     });
     // add middleware
     $this->addMiddleware(new AuthMiddleware());
     $this->route = new Route($this->slim);
     $this->route->run();
     $this->slim->run();
 }
開發者ID:nuiz,項目名稱:duragres,代碼行數:18,代碼來源:Main.php

示例11: 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

示例12: dirname

 *
 * @author Jairo E. Vengoechea R.
 *
 */
session_start();
/** @constant __PUBLIC__ Public folder*/
define('__PUBLIC__', dirname(__FILE__));
/** @constant __ROOT__ Root folder*/
define('__ROOT__', dirname(dirname(__FILE__)));
/** @constant __DEV__ */
define('__DEV__', true);
/** Config */
require_once __ROOT__ . '/routing/config.php';
//Importing config.php
require_once __ROOT__ . '/core/MCN.php';
use MCN\MCN;
//Importing Bower Includer
require_once __ROOT__ . '/core/Includer.php';
//vendors
require_once __ROOT__ . '/vendor/autoload.php';
//initiate DB
use RedBeanPHP\R;
R::setup('mysql:host=' . $config['dbhost'] . ';dbname=' . $config['dbname'], $config['dbuser'], $config['dbpass']);
R::setAutoResolve(TRUE);
//initialising the app
$MCN = new MCN();
$includes = $MCN->includes();
foreach ($includes as $inc) {
    require_once $inc;
}
$MCN->route();
開發者ID:pixeledchimp,項目名稱:michino,代碼行數:31,代碼來源:index.php

示例13: error_reporting

<?php

//turn all reporting on
error_reporting(E_ALL);
ini_set('display_errors', 1);
require 'vendor/autoload.php';
\RedBeanPHP\R::setup('mysql:host=localhost;dbname=db_smi', 'root', 'root');
$logWriter = new \Slim\LogWriter(fopen(__DIR__ . '/logs/log-' . date('Y-m-d', time()), 'a'));
$customConfig = array();
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim(array('log.writer' => $logWriter, 'custom' => $customConfig));
/*
$app->add(new \Slim\Middleware\HttpBasicAuthentication([
    "realm" => "Protected",
    "relaxed" => array("localhost"),
    "users" => [
        "root" => "r0Ot_C0n643"
    ]
]));
*/
//Including all resources
foreach (glob("resources/*.php") as $filename) {
    require_once $filename;
}
$app->run();
開發者ID:tezrosolutions,項目名稱:slim-redbeans,代碼行數:25,代碼來源:index.php

示例14: date_default_timezone_set

<?php

// set the timezone
date_default_timezone_set('Europe/London');
// -----------------------------------------------------------------------------
// Service factories
// -----------------------------------------------------------------------------
// monolog
$container['logger'] = function ($c) {
    $settings = $c['settings']['logger'];
    $logger = new \Monolog\Logger($settings['name']);
    $logger->pushProcessor(new \Monolog\Processor\UidProcessor());
    $logger->pushHandler(new \Monolog\Handler\StreamHandler($settings['path'], \Monolog\Logger::DEBUG));
    return $logger;
};
$container['dsn'] = function ($c) {
    $settings = $c['settings']['database'];
    $dsn = $settings['driver'] . ':host=' . $settings['host'] . (!empty($settings['port']) ? ';port=' . $settings['port'] : '') . ';dbname=' . $settings['database'];
    return $dsn;
};
$frozen = $container['settings']['database']['frozen'];
//with namespace Model
define('REDBEAN_MODEL_PREFIX', '\\App\\Models\\');
\RedBeanPHP\R::setup($container['dsn'], $container['settings']['database']['username'], $container['settings']['database']['password'], $frozen);
// database mysqli connection
$container['database'] = function ($c) {
    $settings = $c['settings']['database'];
    $connection = new \PDO($c['dsn'], $settings['username'], $settings['password']);
    //$connection = new mysqli($settings['host'], $settings['username'], $settings['password'], $settings['database']);
    return $connection;
};
開發者ID:neilmillard,項目名稱:fxtrader,代碼行數:31,代碼來源:dependencies.php

示例15: Router

use router\Router;
use RedBeanPHP\R;
use http\HttpContext;
use handler\Handlers;
use handler\json\JsonHandler;
use handler\http\HttpStatusHandler;
use handler\json\Json;
use handler\http\HttpStatus;
use http\HttpSession;
use auth\service\HttpAuth;
use auth\provider\HtpasswdProvider;
include __DIR__ . '/../vendor/autoload.php';
include 'Model_Post.php';
// setup database
R::setup('sqlite:../db/dbfile.db');
// all dates in UTC timezone
date_default_timezone_set("UTC");
ini_set('date.timezone', 'UTC');
$router = new Router();
$auth = new HttpAuth(new HtpasswdProvider('../db/.htpasswd'), 'Posts admin');
$handlers = Handlers::get();
$handlers->add(new JsonHandler());
$handlers->add(new HttpStatusHandler());
/**
 * Fetch all posts
 *
 * @return Json array with all posts
 */
$router->route('posts-list', '/posts', function () {
    $result = [];
開發者ID:elgervb,項目名稱:blog,代碼行數:30,代碼來源:index.php


注:本文中的RedBeanPHP\R::setup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。