当前位置: 首页>>代码示例>>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;未经允许,请勿转载。