当前位置: 首页>>代码示例>>PHP>>正文


PHP ConnectionManager::enumConnectionObjects方法代码示例

本文整理汇总了PHP中ConnectionManager::enumConnectionObjects方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionManager::enumConnectionObjects方法的具体用法?PHP ConnectionManager::enumConnectionObjects怎么用?PHP ConnectionManager::enumConnectionObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConnectionManager的用法示例。


在下文中一共展示了ConnectionManager::enumConnectionObjects方法的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: _isDatasourceAvailable

 protected static function _isDatasourceAvailable($datasource = 'default')
 {
     if (self::_instantiated($datasource)) {
         return true;
     }
     $sourceList = ConnectionManager::enumConnectionObjects();
     return array_key_exists($datasource, $sourceList);
 }
开发者ID:hiromi2424,项目名称:ninja,代码行数:8,代码来源:transaction_manager.php

示例3: setUp

 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->Model = new StripeAppModel();
     $this->Model->setDataSource('stripe_test');
     $sources = ConnectionManager::enumConnectionObjects();
     $this->skipIf(!in_array('stripe_test', array_keys($sources)), '`stripe_test` db config not found');
 }
开发者ID:pratik-neptrox,项目名称:stripe,代码行数:13,代码来源:StripeAppTest.php

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

示例5: setUp

 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->Model = new StripeCustomer();
     $this->Model->setDataSource('stripe_test');
     $sources = ConnectionManager::enumConnectionObjects();
     $this->skipIf(!in_array('stripe_test', array_keys($sources)), '`stripe_test` db config not found');
     $this->Source = $this->Model->getDataSource('stripe_test');
     $this->Source->Http = $this->getMock('HttpSocket', array('request'));
 }
开发者ID:pratik-neptrox,项目名称:stripe,代码行数:15,代码来源:StripeCustomerTest.php

示例6: 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);
     $this->Mongo = new MongodbSource($this->_config);
     $this->Post = ClassRegistry::init(array('class' => 'SqlCompatiblePost', 'alias' => 'Post', 'ds' => 'mongo_test'));
     $this->_setupData();
 }
开发者ID:ZachGambino-GG,项目名称:cakephp-mongodb,代码行数:18,代码来源:sql_compatible.test.php

示例7: setUp

 public function setUp()
 {
     $connections = ConnectionManager::enumConnectionObjects();
     if (!empty($connections['test']['classname']) && $connections['test']['classname'] === 'mongodbSource') {
         $config = new DATABASE_CONFIG();
         $this->_config = $config->test;
     }
     if (!isset($connections['test_mongo'])) {
         ConnectionManager::create('test_mongo', $this->_config);
         $this->Mongo = new MongodbSource($this->_config);
     }
     $this->Post = ClassRegistry::init(array('class' => 'SqlCompatiblePost', 'alias' => 'Post', 'ds' => 'test_mongo'), true);
 }
开发者ID:indirasam,项目名称:aquitemmata,代码行数:13,代码来源:SqlCompatibleTest.php

示例8: getConfig

 /**
  * Get a user specified Connection name
  *
  * @return void
  */
 public function getConfig()
 {
     App::uses('ConnectionManager', 'Model');
     $configs = ConnectionManager::enumConnectionObjects();
     $useDbConfig = key($configs);
     if (!is_array($configs) || empty($configs)) {
         return $this->execute();
     }
     $connections = array_keys($configs);
     if (count($connections) > 1) {
         $useDbConfig = $this->in(__d('cake_console', 'Use Database Config') . ':', $connections, $useDbConfig);
     }
     return $useDbConfig;
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:19,代码来源:DbConfigTask.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);
     $this->Mongo = new MongodbSource($this->_config);
     $this->Post = ClassRegistry::init('Post');
     $this->Post->setDataSource('mongo_test');
     $this->mongodb =& ConnectionManager::getDataSource($this->Post->useDbConfig);
     $this->dropData();
 }
开发者ID:r0mk1n,项目名称:cakephp-mongodb,代码行数:20,代码来源:mongodb_source.test.php

示例10: getSlave

 private function getSlave()
 {
     if (!defined('APP_DEV') || APP_DEV) {
         return $this->useDbConfig;
     }
     $sources_list = ConnectionManager::enumConnectionObjects();
     $slaves = array();
     foreach ($sources_list as $name => $values) {
         if (preg_match('/^slave[0-9]+$/i', $name) == 1) {
             $slaves[] = $name;
         }
     }
     return $slaves[rand(0, count($slaves) - 1)];
 }
开发者ID:RichardPear,项目名称:todo,代码行数:14,代码来源:AppModel.php

示例11: _initDb

 protected function _initDb()
 {
     $testDbAvailable = in_array('test', array_keys(ConnectionManager::enumConnectionObjects()));
     if ($testDbAvailable) {
         // Try for test DB
         restore_error_handler();
         $db = ConnectionManager::getDataSource('test');
         $testDbAvailable = $db->isConnected();
     }
     // Try for default DB
     if (!$testDbAvailable) {
         $db = ConnectionManager::getDataSource('default');
         $db->config['prefix'] = 'test_suite_';
     }
     ConnectionManager::create('test_suite', $db->config);
     ClassRegistry::config(array('ds' => 'test_suite'));
 }
开发者ID:nojimage,项目名称:Bdd,代码行数:17,代码来源:SpecShell.php

示例12: authorize

 public function authorize($user, \CakeRequest $request)
 {
     $dbs = ConnectionManager::enumConnectionObjects();
     $connNames = array_keys($dbs);
     $Apis = key($this->settings['Apis']) === 0 ? $this->settings['Apis'] : array_keys($this->settings['Apis']);
     $apiNames = array_intersect($Apis, $connNames);
     $authorized = true;
     foreach ($apiNames as $name) {
         $storeMethod = empty($this->settings['Apis'][$name]['store']) ? 'Db' : ucfirst($this->settings['Apis'][$name]['store']);
         $Store = $this->_getTokenStore($storeMethod);
         if ($Store instanceof TokenStoreInterface) {
             $allowed = $Store->checkToken($name, $user['id']);
         }
         $this->controller()->Apis[$name]['authorized'] = $allowed;
         if (!$allowed) {
             $authorized = false;
         }
     }
     return $authorized;
 }
开发者ID:mohitkochhar,项目名称:Copula,代码行数:20,代码来源:OauthAuthorize.php

示例13: _initDb

 /**
  * Initializes this class with a DataSource object to use as default for all fixtures
  *
  * @return void
  */
 protected function _initDb()
 {
     if ($this->_initialized) {
         return;
     }
     $testDbAvailable = in_array('test', array_keys(ConnectionManager::enumConnectionObjects()));
     $_prefix = null;
     if ($testDbAvailable) {
         // Try for test DB
         @($db = ConnectionManager::getDataSource('test'));
         $testDbAvailable = $db->isConnected();
     } else {
         throw new MissingConnectionException(__('You need to create a $test datasource connection to start using fixtures'));
     }
     if (!$testDbAvailable) {
         throw new MissingConnectionException(__('Unable to connect to the $test datasource'));
     }
     $this->_db = $db;
     ClassRegistry::config(array('ds' => 'test'));
     $this->_initialized = true;
 }
开发者ID:robotarmy,项目名称:Phog,代码行数:26,代码来源:cake_fixture_manager.php

示例14: main

 /**
  * Truncates all tables and loads fixtures into db
  *
  * @return void
  * @access public
  */
 function main()
 {
     if (!empty($this->args) && $this->args[0] != 'all') {
         $fixtures = $this->args;
         foreach ($fixtures as $i => $fixture) {
             $fixtures[$i] = APP . 'tests/fixtures/' . $fixture . '_fixture.php';
         }
     } elseif (!empty($this->args) && $this->args[0] == 'all') {
         App::import('Folder');
         $Folder = new Folder(APP . 'tests/fixtures');
         $fixtures = $Folder->findRecursive('.+_fixture\\.php');
     } else {
         $this->out('Usage: cake fixtures [ all | <table-name-singluar> ]');
         return;
     }
     $datasource = 'default';
     if (isset($this->params['datasource'])) {
         $datasource = $this->params['datasource'];
     }
     $list = ConnectionManager::enumConnectionObjects();
     if (!isset($list[$datasource])) {
         $this->error("Data Source", "Non-existent data source '{$datasource}'");
     }
     $db = ConnectionManager::getDataSource($datasource);
     $records = 0;
     foreach ($fixtures as $path) {
         require_once $path;
         $name = str_replace('_fixture.php', '', basename($path));
         $class = Inflector::camelize($name) . 'Fixture';
         $Fixture =& new $class($db);
         $this->out('-> Truncating table "' . $Fixture->table . '"');
         $db->truncate($Fixture->table);
         $Fixture->insert($db);
         $fixtureRecords = count($Fixture->records);
         $records += $fixtureRecords;
         $this->out('-> Inserting ' . $fixtureRecords . ' records for "' . $Fixture->table . '"');
     }
     $this->out(sprintf('-> Done inserting %d records for %d tables', $records, count($fixtures)));
 }
开发者ID:jamiemill,项目名称:missioncontrol_core,代码行数:45,代码来源:fixtures.php

示例15: __construct

 /**
  * Sets up the configuration for the model, and loads databse from Multi Tenant Site
  *
  * @param Model $model Model using this behavior.
  * @param array $config Configuration options.
  * @return void
  */
 public function __construct($id = false, $table = null, $ds = null)
 {
     // usar el correspondiente al tenant
     //debug( Router::$_requests );
     if (CakeSession::started()) {
         $currentTenant = MtSites::getSiteName();
         if ($currentTenant) {
             // listar sources actuales
             $sources = ConnectionManager::enumConnectionObjects();
             //copiar del default
             $tenantConf = $sources['default'];
             // colocar el nombre de la base de datos
             $tenantConf['database'] = $tenantConf['database'] . "_" . $currentTenant;
             // crear la conexion con la bd
             $confName = 'tenant_' . $currentTenant;
             ConnectionManager::create($confName, $tenantConf);
             // usar tenant para este model
             $this->useDbConfig = $confName;
         }
     }
     // ahora construir el Model
     parent::__construct($id, $table, $ds);
 }
开发者ID:ristorantino,项目名称:users,代码行数:30,代码来源:RolUser.php


注:本文中的ConnectionManager::enumConnectionObjects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。