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


PHP ConnectionManager::create方法代碼示例

本文整理匯總了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'));
 }
開發者ID:rodrigorm,項目名稱:selenium-helper,代碼行數:31,代碼來源:database.php

示例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;
 }
開發者ID:ahmadhasankhan,項目名稱:croogo,代碼行數:33,代碼來源:InstallManager.php

示例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();
 }
開發者ID:mohitkochhar,項目名稱:Copula,代碼行數:8,代碼來源:RemoteTokenSourceTest.php

示例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);
 }
開發者ID:kingsolmn,項目名稱:CakePHP-Braintree-Plugin,代碼行數:18,代碼來源:braintree_app_model.php

示例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();
 }
開發者ID:hardsshah,項目名稱:yahoo_boss,代碼行數:8,代碼來源:search.php

示例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();
 }
開發者ID:aniltc,項目名稱:cakephp-plugin-google-analytics,代碼行數:8,代碼來源:google_analytics_account.php

示例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');
 }
開發者ID:mohitkochhar,項目名稱:Copula,代碼行數:8,代碼來源:ApisSourceTest.php

示例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();
 }
開發者ID:neilcrookes,項目名稱:gdata,代碼行數:12,代碼來源:analytic.php

示例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);
 }
開發者ID:ThemisB,項目名稱:mongoDB-Datasource,代碼行數:15,代碼來源:first_mongodb_source.test.php

示例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);
 }
開發者ID:pefringant,項目名稱:twitter,代碼行數:9,代碼來源:twitter.php

示例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();
 }
開發者ID:neilcrookes,項目名稱:gdata,代碼行數:12,代碼來源:picasa.php

示例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);
 }
開發者ID:niltonfelipe,項目名稱:e-cidade_transparencia,代碼行數:9,代碼來源:cms_app_model.php

示例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');
 }
開發者ID:areisv,項目名稱:cakewell,代碼行數:10,代碼來源:twitter_controller.php

示例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();
 }
開發者ID:areisv,項目名稱:cakewell,代碼行數:10,代碼來源:twitter.php

示例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();
 }
開發者ID:asadaqain,項目名稱:Guide-on-the-Side,代碼行數:15,代碼來源:couchdb_source.test.php


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