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


PHP ConnectionManager::sourceList方法代码示例

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


在下文中一共展示了ConnectionManager::sourceList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Adds the datasource to the Connection Manager's list of sources if it is
  * not already there. It would normally be there if you add the datasource
  * details to your app/config/database.php file, but this code negates the
  * need to do that. It adds the datasource for the current model being
  * constructed with default basic configuration options, and extra options
  * from the GDATA_CONFIG->{$this->useDbConfig} class property from the file in
  * plugins/gdata/config/gdata_config.php if it exists, and extra options from
  * Gdata.config key in the Configure class, if set. Options should include
  * X-GData-Key as a minimum if required by the Gdata API, and also optionally
  * oauth_consumer_key, oauth_consumer_secret, oauth_token and
  * oauth_token_secret keys
  *
  * @param mixed $id
  * @param string $table
  * @param mixed $ds
  */
 public function __construct($id = false, $table = null, $ds = null)
 {
     // Get the list of datasource that the ConnectionManager is aware of
     $sources = ConnectionManager::sourceList();
     // If this model's datasource isn't in it, add it
     if (!in_array($this->useDbConfig, $sources)) {
         // Default minimum config
         $config = array('datasource' => 'Gdata.GdataSource', 'driver' => 'Gdata.' . Inflector::camelize($this->useDbConfig));
         // Try an import the plugins/gdata/config/gdata_config.php file and merge
         // any default and datasource specific config with the defaults above
         if (App::import(array('type' => 'File', 'name' => 'Gdata.GDATA_CONFIG', 'file' => 'config' . DS . 'gdata_config.php'))) {
             $GDATA_CONFIG = new GDATA_CONFIG();
             if (isset($GDATA_CONFIG->default)) {
                 $config = array_merge($config, $GDATA_CONFIG->default);
             }
             if (isset($GDATA_CONFIG->{$this->useDbConfig})) {
                 $config = array_merge($config, $GDATA_CONFIG->{$this->useDbConfig});
             }
         }
         // Add any config from Configure class that you might have added at any
         // point before the model is instantiated.
         if (($configureConfig = Configure::read('Gdata.config')) != false) {
             $config = array_merge($config, $configureConfig);
         }
         // Add the datasource, with it's new config, to the ConnectionManager
         ConnectionManager::create($this->useDbConfig, $config);
     }
     parent::__construct($id, $table, $ds);
 }
开发者ID:neilcrookes,项目名称:CakePHP-GData-Plugin,代码行数:46,代码来源:gdata_app_model.php

示例2: beforeRender

 /**
  * Gets the connection names that should have logs + dumps generated.
  *
  * @param Controller $controller The controller.
  * @return array
  */
 public function beforeRender(Controller $controller)
 {
     if (!class_exists('ConnectionManager')) {
         return array();
     }
     $connections = array();
     $dbConfigs = ConnectionManager::sourceList();
     foreach ($dbConfigs as $configName) {
         $driver = null;
         $db = ConnectionManager::getDataSource($configName);
         if (empty($db->config['driver']) && empty($db->config['datasource']) || !method_exists($db, 'getLog')) {
             continue;
         }
         if (isset($db->config['datasource'])) {
             $driver = $db->config['datasource'];
         }
         $explain = false;
         $isExplainable = preg_match('/(Mysql|Postgres)$/', $driver);
         if ($isExplainable) {
             $explain = true;
         }
         $connections[$configName] = $explain;
     }
     return array('connections' => $connections, 'threshold' => $this->slowRate);
 }
开发者ID:gjcamacho,项目名称:blog_test,代码行数:31,代码来源:SqlLogPanel.php

示例3: __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

示例4: setTwitterSource

 /**
  * set DataSource Object
  *
  * @param string $datasource
  */
 public function setTwitterSource($datasource)
 {
     if (empty($datasource) || !in_array($datasource, array_keys(get_class_vars('DATABASE_CONFIG'))) && !in_array($datasource, ConnectionManager::sourceList())) {
         return;
     }
     $this->settings['datasource'] = $datasource;
     $this->getTwitterSource();
 }
开发者ID:hiromi2424,项目名称:twitter_kit,代码行数:13,代码来源:twitter.php

示例5: setUp

 function setUp()
 {
     parent::setUp();
     // set up cache
     Cache::write('Cache.disable', false);
     // set up default cache config for tests
     Cache::config('default', array('engine' => 'File', 'duration' => '+6 hours', 'prefix' => 'cacher_tests_', 'path' => CACHE));
     $this->CacheData = ClassRegistry::init('CacheData');
     if (!in_array('cacher', ConnectionManager::sourceList())) {
         ConnectionManager::create('cacher', array('original' => $this->CacheData->useDbConfig, 'datasource' => 'Cacher.CacheSource'));
     }
     $this->dataSource = new CacheSourceTest(array('original' => $this->CacheData->useDbConfig));
 }
开发者ID:jeremyharris,项目名称:cacher,代码行数:13,代码来源:CacheSourceTest.php

示例6: beforeFilter

 /**
  * beforeFilter
  *
  * @return void
  */
 public function beforeFilter()
 {
     parent::beforeFilter();
     set_time_limit(300);
     /* インストール状態判別 */
     if (file_exists(APP . 'Config' . DS . 'database.php')) {
         ConnectionManager::sourceList();
         $db = ConnectionManager::$config;
         if ($db->default['datasource'] != '') {
             $installed = 'complete';
         } else {
             $installed = 'half';
         }
     } else {
         $installed = 'yet';
     }
     switch ($this->request->action) {
         case 'alert':
             break;
         case 'reset':
             if (Configure::read('debug') != -1) {
                 $this->notFound();
             }
             break;
         default:
             if ($installed == 'complete') {
                 if ($this->request->action != 'step5') {
                     $this->notFound();
                 }
             } else {
                 $installationData = Cache::read('Installation', 'default');
                 if (empty($installationData['lastStep'])) {
                     if (Configure::read('debug') == 0) {
                         $this->redirect(array('action' => 'alert'));
                     }
                 }
             }
             break;
     }
     /*if (strpos($this->request->webroot, 'webroot') === false) {
     			$this->request->webroot = DS;
     		}*/
     $this->Security->csrfCheck = false;
     $this->Security->validatePost = false;
 }
开发者ID:baserproject,项目名称:basercms,代码行数:50,代码来源:InstallationsController.php

示例7: setup

 /**
  * Sets up a connection using passed settings
  *
  * ### Config
  * - `config` The name of an existing Cache configuration to use. Default is 'default'
  * - `clearOnSave` Whether or not to delete the cache on saves
  * - `clearOnDelete` Whether or not to delete the cache on deletes
  * - `auto` Automatically cache or look for `'cache'` in the find conditions
  *		where the key is `true` or a duration
  *
  * @param Model $Model The calling model
  * @param array $config Configuration settings
  * @see Cache::config()
  */
 public function setup(Model $Model, $config = array())
 {
     $_defaults = array('config' => 'default', 'clearOnDelete' => true, 'clearOnSave' => true, 'auto' => false, 'gzip' => false);
     $settings = array_merge($_defaults, $config);
     $Model->_useDbConfig = $Model->useDbConfig;
     $ds = ConnectionManager::getDataSource($Model->useDbConfig);
     if (!in_array('cacher', ConnectionManager::sourceList())) {
         $settings += array('original' => $Model->useDbConfig, 'datasource' => 'Cacher.CacheSource');
         $settings = array_merge($ds->config, $settings);
         ConnectionManager::create('cacher', $settings);
     } else {
         $ds = ConnectionManager::getDataSource('cacher');
         $ds->config = array_merge($ds->config, $settings);
     }
     if (!isset($this->settings[$Model->alias])) {
         $this->settings[$Model->alias] = $settings;
     }
     $this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], $settings);
 }
开发者ID:jeremyharris,项目名称:cacher,代码行数:33,代码来源:CacheBehavior.php

示例8: setup

 /**
  * Sets up a connection using passed settings
  *
  * ### Config
  * - `config` The name of an existing Cache configuration to use. Default is 'default'
  * - `clearOnSave` Whether or not to delete the cache on saves
  * - `clearOnDelete` Whether or not to delete the cache on deletes
  * - `auto` Automatically cache or look for `'cache'` in the find conditions
  * 		where the key is `true` or a duration
  *
  * @param Model $model The calling model
  * @param array $config Configuration settings
  * @return void
  * @see Cache::config()
  */
 public function setup(Model $model, $config = array())
 {
     $settings = array_merge($this->_defaults, $config);
     // Modified and set config for CachedSoure by behavior setting
     $ds = ConnectionManager::getDataSource($model->useDbConfig);
     $dsConfig = array_merge($ds->config, array('original' => $model->useDbConfig, 'datasource' => 'Cache.CachedSource', 'config' => $settings['config'], 'map' => $settings['map'], 'gzip' => $settings['gzip']));
     if (!in_array('cached', ConnectionManager::sourceList())) {
         ConnectionManager::create('cached', $dsConfig);
     } else {
         $ds = ConnectionManager::getDataSource('cached');
         $ds->setConfig($dsConfig);
     }
     // Merge behavior setting
     if (!isset($this->settings[$model->alias])) {
         $this->settings[$model->alias] = $settings;
     } else {
         $this->settings[$model->alias] = array_merge($this->settings[$model->alias], $settings);
     }
     return parent::setup($model, $config);
 }
开发者ID:oanhnn,项目名称:cache,代码行数:35,代码来源:CachedBehavior.php

示例9: startUp

 /**
  * get db configs.
  *
  * @param string $controller
  * @access public
  * @return void
  */
 function startUp(&$controller)
 {
     if (!class_exists('ConnectionManager')) {
         $this->dbConfigs = array();
         return false;
     }
     $this->dbConfigs = ConnectionManager::sourceList();
     return true;
 }
开发者ID:TomMaher,项目名称:umambo,代码行数:16,代码来源:toolbar.php

示例10: beforeRender

 /**
  * Gets the connection names that should have logs + dumps generated.
  *
  * @param string $controller
  * @access public
  * @return void
  */
 function beforeRender(&$controller)
 {
     if (!class_exists('ConnectionManager')) {
         return array();
     }
     $connections = array();
     $dbConfigs = ConnectionManager::sourceList();
     foreach ($dbConfigs as $configName) {
         $db =& ConnectionManager::getDataSource($configName);
         $driver = $db->config['driver'];
         $explain = false;
         $isExplainable = $driver === 'mysql' || $driver === 'mysqli' || $driver === 'postgres';
         if ($isExplainable && $db->isInterfaceSupported('getLog')) {
             $explain = true;
         }
         $connections[$configName] = $explain;
     }
     return array('connections' => $connections, 'threshold' => $this->slowRate);
 }
开发者ID:sdoney,项目名称:infinitas,代码行数:26,代码来源:toolbar.php

示例11: sqlDump

 /**
  * Shows sql dump
  * 
  * @param bool $sorted Get the queries sorted by time taken, defaults to false.
  * @param bool $clear If True the existing log will cleared.
  */
 public function sqlDump($sorted = false, $clear = true)
 {
     if (!class_exists('ConnectionManager') || Configure::read('debug') < 2) {
         return;
     }
     $sources = ConnectionManager::sourceList();
     $logs = array();
     foreach ($sources as $source) {
         $db = ConnectionManager::getDataSource($source);
         if (!method_exists($db, 'getLog')) {
             continue;
         }
         $logs[$source] = $db->getLog($sorted, $clear);
     }
     if (empty($logs)) {
         return;
     }
     $this->out('<b>SQL dump:</b>');
     foreach ($logs as $source => $log) {
         $this->out("<b>Source: {$source}, queries: {$log['count']}, took: {$log['time']}ms</b>");
         foreach ($log['log'] as $k => $i) {
             $i += array('error' => '');
             $this->out($k + 1 . ". {$i['query']} <sqlinfo>{e:{$i['error']}, a:{$i['affected']}, t:{$i['took']}, n:{$i['numRows']}}</sqlinfo>");
         }
     }
 }
开发者ID:imsamurai,项目名称:cakephp-advancedshell,代码行数:32,代码来源:AdvancedShell.php

示例12: getDataSource

 /**
  * Returns the datasource object for the current controller's modelClass
  *
  * @return DataSource object
  */
 public function getDataSource()
 {
     // Get the list of datasources that the ConnectionManager is aware of
     $sources = ConnectionManager::sourceList();
     // If the twitter datasource is in it, return it
     if (in_array('twitter', $sources)) {
         return ConnectionManager::getDataSource('twitter');
     }
     App::import('DataSource', 'Twitter.TwitterSource');
     return new TwitterSource();
 }
开发者ID:neilcrookes,项目名称:CakePHP-Twitter-API-Plugin,代码行数:16,代码来源:twitter_auth.php

示例13: testSetup

 function testSetup()
 {
     $this->CacheData->Behaviors->attach('Cacher.Cache', array('duration' => '+1 days'));
     $this->assertTrue(in_array('cacher', ConnectionManager::sourceList()));
     $this->assertEquals($this->CacheData->_useDbConfig, 'test');
     $this->assertEquals($this->CacheData->useDbConfig, 'test');
 }
开发者ID:jeremyharris,项目名称:cacher,代码行数:7,代码来源:CacheBehaviorTest.php

示例14: beforeRender

 /**
  * Get Sql Logs for each DB config
  *
  * @param string $controller
  * @access public
  * @return void
  */
 function beforeRender(&$controller)
 {
     $queryLogs = array();
     if (!class_exists('ConnectionManager')) {
         return array();
     }
     $dbConfigs = ConnectionManager::sourceList();
     foreach ($dbConfigs as $configName) {
         $db =& ConnectionManager::getDataSource($configName);
         if ($db->isInterfaceSupported('showLog')) {
             ob_start();
             $db->showLog();
             $queryLogs[$configName] = ob_get_clean();
         }
     }
     return $queryLogs;
 }
开发者ID:kondrat,项目名称:agift,代码行数:24,代码来源:toolbar.php

示例15: _cake_constants

 function _cake_constants()
 {
     $Constants = array('Cake Constants' => array('APP' => APP, 'APP_DIR' => APP_DIR, 'APP_PATH' => APP_PATH, 'CACHE' => CACHE, 'CAKE' => CAKE, 'CAKE_CORE_INCLUDE_PATH' => CAKE_CORE_INCLUDE_PATH, 'COMPONENTS' => COMPONENTS, 'CONFIGS' => CONFIGS, 'CONTROLLER_TESTS' => CONTROLLER_TESTS, 'CONTROLLERS' => CONTROLLERS, 'CORE_PATH' => CORE_PATH, 'CSS' => CSS, 'DEBUG (use Configure::read("debug"))' => DEBUG, 'ELEMENTS' => ELEMENTS, 'FULL_BASE_URL' => FULL_BASE_URL, 'FULL_BASE_URL . Router::url(\'\', false)' => FULL_BASE_URL . Router::url('', false), 'HELPER_TESTS' => HELPER_TESTS, 'HELPERS' => HELPERS, 'INFLECTIONS' => INFLECTIONS, 'JS' => JS, 'LAYOUTS' => LAYOUTS, 'LIB_TESTS' => LIB_TESTS, 'LIBS' => LIBS, 'LOGS' => LOGS, 'MODEL_TESTS' => MODEL_TESTS, 'MODELS' => MODELS, 'PROJECT_ROOT (Cakewell only)' => PROJECT_ROOT, 'TESTS' => TESTS, 'TMP' => TMP, 'ROOT' => ROOT, 'VENDORS' => VENDORS, 'VIEWS' => VIEWS, 'WEBROOT_DIR' => WEBROOT_DIR, 'WWW_ROOT' => WWW_ROOT), 'Controller Properties' => array('$this->action' => $this->action, '$this->here' => $this->here, '$this->name' => $this->name, '$this->params[\'url\']' => $this->params['url']), 'Other' => array('ConnectionManager::sourceList' => ConnectionManager::sourceList(), 'Configure Class Settings' => 'see config_test'));
     return $Constants;
 }
开发者ID:areisv,项目名称:cakewell,代码行数:5,代码来源:demo_controller.php


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