本文整理汇总了PHP中ConnectionManager::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionManager::create方法的具体用法?PHP ConnectionManager::create怎么用?PHP ConnectionManager::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionManager
的用法示例。
在下文中一共展示了ConnectionManager::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configure
static function configure()
{
if (empty($_COOKIE['selenium'])) {
return;
}
$cookie = $_COOKIE['selenium'];
App::import('Model', 'ConnectionManager', false);
ClassRegistry::flush();
Configure::write('Cache.disable', true);
$testDbAvailable = in_array('test', array_keys(ConnectionManager::enumConnectionObjects()));
$_prefix = null;
if ($testDbAvailable) {
// Try for test DB
restore_error_handler();
@($db =& ConnectionManager::getDataSource('test'));
set_error_handler('simpleTestErrorHandler');
$testDbAvailable = $db->isConnected();
}
// Try for default DB
if (!$testDbAvailable) {
$db =& ConnectionManager::getDataSource('default');
}
$_prefix = $db->config['prefix'];
$db->config['prefix'] = $cookie . '_';
ConnectionManager::create('test_suite', $db->config);
$db->config['prefix'] = $_prefix;
// Get db connection
$db =& ConnectionManager::getDataSource('test_suite');
$db->cacheSources = false;
ClassRegistry::config(array('ds' => 'test_suite'));
}
示例2: createDatabaseFile
public function createDatabaseFile($data)
{
App::uses('File', 'Utility');
App::uses('ConnectionManager', 'Model');
$config = $this->defaultConfig;
foreach ($data['Install'] as $key => $value) {
if (isset($data['Install'][$key])) {
$config[$key] = $value;
}
}
$result = copy(APP . 'Config' . DS . 'database.php.install', APP . 'Config' . DS . 'database.php');
if (!$result) {
return __d('croogo', 'Could not copy database.php file.');
}
$file = new File(APP . 'Config' . DS . 'database.php', true);
$content = $file->read();
foreach ($config as $configKey => $configValue) {
$content = str_replace('{default_' . $configKey . '}', $configValue, $content);
}
if (!$file->write($content)) {
return __d('croogo', 'Could not write database.php file.');
}
try {
ConnectionManager::create('default', $config);
$db = ConnectionManager::getDataSource('default');
} catch (MissingConnectionException $e) {
return __d('croogo', 'Could not connect to database: ') . $e->getMessage();
}
if (!$db->isConnected()) {
return __d('croogo', 'Could not connect to database.');
}
return true;
}
示例3: setUp
public function setUp()
{
parent::setUp();
$config = array('datasource' => 'Copula.RemoteTokenSource', 'login' => 'login', 'password' => 'password', 'authMethod' => 'OAuth', 'scheme' => 'https', 'authorize' => 'auth', 'access' => 'token', 'host' => 'accounts.example.com/oauth2', 'scope' => 'https://www.exampleapis.com/auth/', 'callback' => 'https://www.mysite.com/oauth2callback');
$this->Source = ConnectionManager::create('testapi', $config);
$this->Source->Http = $this->getMock('HttpSocketOauth', array('request'));
$this->Model = new Model();
}
示例4: __construct
/**
* Adds the datasource to the connection manager if it's not already there,
* which it won't be if you've not added it to your app/config/database.php
* file.
*
* @param $id
* @param $table
* @param $ds
* @return void
*/
public function __construct($id = false, $table = null, $ds = null)
{
$sources = ConnectionManager::sourceList();
if (!in_array('braintree', $sources)) {
ConnectionManager::create('braintree', array('datasource' => 'Braintree.BraintreeSource'));
}
parent::__construct($id, $table, $ds);
}
示例5: __construct
function __construct()
{
App::import(array('type' => 'File', 'name' => 'YahooBoss.YAHOO_BOSS_CONFIG', 'file' => 'config' . DS . 'yahoo_boss.php'));
App::import(array('type' => 'File', 'name' => 'YahooBoss.YahooBossSource', 'file' => 'models' . DS . 'datasources' . DS . 'yahoo_boss_source.php'));
$config =& new YAHOO_BOSS_CONFIG();
ConnectionManager::create('yahooBoss', $config->yahooBoss);
parent::__construct();
}
示例6: __construct
function __construct()
{
App::import(array('type' => 'File', 'name' => 'GoogleAnalytics.GOOGLE_ANALYTICS_CONFIG', 'file' => 'config' . DS . 'google_analytics.php'));
App::import(array('type' => 'File', 'name' => 'GoogleAnalytics.GoogleAnalyticsSource', 'file' => 'models' . DS . 'datasources' . DS . 'google_analytics_source.php'));
$config =& new GOOGLE_ANALYTICS_CONFIG();
ConnectionManager::create('googleAnalytics', $config->googleAnalytics);
parent::__construct();
}
示例7: setUp
public function setUp()
{
parent::setUp();
Configure::write('Copula.testapi.path', $this->paths);
Configure::write('Copula.testapi.Api', $this->config);
$this->Apis = ConnectionManager::create('testapi', $this->dbconf);
$this->model = ClassRegistry::init('CopulaTestModel');
}
示例8: __construct
/**
* Imports the datasources from the plugin and adds to the connection manager
*/
function __construct()
{
App::import(array('type' => 'File', 'name' => 'Gdata.GDATA_CONFIG', 'file' => 'config' . DS . 'gdata_config.php'));
App::import(array('type' => 'File', 'name' => 'Gdata.GdataSource', 'file' => 'models' . DS . 'datasources' . DS . 'gdata_source.php'));
App::import(array('type' => 'File', 'name' => 'Gdata.GdataAnalyticsSource', 'file' => 'models' . DS . 'datasources' . DS . 'gdata' . DS . 'gdata_analytics.php'));
$config =& new GDATA_CONFIG();
ConnectionManager::create('analytics', $config->analytics);
parent::__construct();
}
示例9: startTest
/**
* Sets up the environment for each test method
*
* @return void
* @access public
*/
public function startTest()
{
$connections = ConnectionManager::enumConnectionObjects();
if (!empty($connections['test']['classname']) && $connections['test']['classname'] === 'mongodbSource') {
$config = new DATABASE_CONFIG();
$this->_config = $config->test;
}
ConnectionManager::create('mongo_test', $this->_config);
}
示例10: __construct
function __construct()
{
// Datasource config
App::import(array('type' => 'File', 'name' => 'Twitter.TWITTER_CONFIG', 'file' => 'config' . DS . 'twitter.php'));
// Datasource
App::import(array('type' => 'File', 'name' => 'Twitter.TwitterSource', 'file' => 'models' . DS . 'datasources' . DS . 'twitter_source.php'));
$config =& new TWITTER_CONFIG();
ConnectionManager::create('twitter', $config->twitter);
}
示例11: __construct
/**
* Imports the datasources from the plugin and adds to the connection manager
*/
public function __construct()
{
App::import(array('type' => 'File', 'name' => 'Gdata.GDATA_CONFIG', 'file' => 'config' . DS . 'gdata_config.php'));
App::import(array('type' => 'File', 'name' => 'Gdata.GdataSource', 'file' => 'models' . DS . 'datasources' . DS . 'gdata_source.php'));
App::import(array('type' => 'File', 'name' => 'Gdata.GdataPicasa', 'file' => 'models' . DS . 'datasources' . DS . 'gdata' . DS . 'gdata_picasa.php'));
$config =& new GDATA_CONFIG();
ConnectionManager::create('picasa', $config->picasa);
parent::__construct();
}
示例12: __construct
public function __construct($id = false, $table = null, $ds = null)
{
$oDatabase = new DATABASE_CONFIG();
$config = $oDatabase->default;
$config["schema"] = "cms";
$ds = ConnectionManager::create("cms", $config);
$this->useDbConfig = "cms";
parent::__construct($id, $table, $ds);
}
示例13: beforeFilter
function beforeFilter()
{
App::Import('ConnectionManager');
App::Import('DataSource');
App::import(array('type' => 'File', 'name' => 'Twitter.TWITTER_CONFIG', 'file' => 'config' . DS . 'core.php'));
App::import(array('type' => 'File', 'name' => 'Twitter.TwitterSource', 'file' => 'models' . DS . 'datasources' . DS . 'twitter_source.php'));
$TwitterConfig =& new TWITTER_CONFIG();
ConnectionManager::create('twitter', $TwitterConfig->login);
$this->Twitter = ConnectionManager::getDataSource('twitter');
}
示例14: __construct
function __construct()
{
App::import(array('type' => 'File', 'name' => 'Twitter.TWITTER_CONFIG', 'file' => 'config' . DS . 'core.php'));
App::import(array('type' => 'File', 'name' => 'Twitter.TwitterSource', 'file' => 'models' . DS . 'datasources' . DS . 'twitter_source.php'));
$TwitterConfig =& new TWITTER_CONFIG();
ConnectionManager::create('twitter', $TwitterConfig->login);
$this->Api = ConnectionManager::getDataSource('twitter');
#debug($config);
parent::__construct();
}
示例15: startTest
/**
* Start Test
*
* @return void
*/
public function startTest()
{
$config = new DATABASE_CONFIG();
if (isset($config->couchdb_test)) {
$this->config = $config->couchdb_test;
}
ConnectionManager::create('couchdb_test', $this->config);
$this->Post = ClassRegistry::init('Post');
$this->removeAllDocuments();
}