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


PHP ConnectionManager::config方法代码示例

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


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

示例1: testWrongCredentials

 /**
  * Tests that connecting with invalid credentials or database name throws an exception
  *
  * @expectedException \Cake\Database\Exception\MissingConnectionException
  * @return void
  */
 public function testWrongCredentials()
 {
     $config = ConnectionManager::config('test');
     $this->skipIf(isset($config['url']), 'Datasource has dsn, skipping.');
     $connection = new Connection(['database' => '/dev/nonexistent'] + ConnectionManager::config('test'));
     $connection->connect();
 }
开发者ID:Slayug,项目名称:castor,代码行数:13,代码来源:ConnectionTest.php

示例2: setUpBeforeClass

 /**
  * Set up some fake datasources and security salt **once** before all tests.
  *
  * @return void
  * @see ::testMainSpecialKeys()
  */
 public static function setUpBeforeClass()
 {
     // Prime the ConnectionManager with some configs.
     \Cake\Datasource\ConnectionManager::config(self::$datasources);
     // Prime the security salt.
     \Cake\Utility\Security::salt(self::$salt);
 }
开发者ID:loadsys,项目名称:cakephp-basic-seed,代码行数:13,代码来源:BasicSeedShellTest.php

示例3: getConfig

 /**
  * Overrides the original method from phinx in order to return a tailored
  * Config object containing the connection details for the database.
  *
  * @return Phinx\Config\Config
  */
 public function getConfig()
 {
     if ($this->configuration) {
         return $this->configuration;
     }
     $folder = 'Migrations';
     if ($this->input->getOption('source')) {
         $folder = $this->input->getOption('source');
     }
     $dir = ROOT . DS . 'config' . DS . $folder;
     $plugin = null;
     if ($this->input->getOption('plugin')) {
         $plugin = $this->input->getOption('plugin');
         $dir = Plugin::path($plugin) . 'config' . DS . $folder;
     }
     if (!is_dir($dir)) {
         mkdir($dir, 0777, true);
     }
     $plugin = $plugin ? Inflector::underscore($plugin) . '_' : '';
     $plugin = str_replace(array('\\', '/', '.'), '_', $plugin);
     $connection = 'default';
     if ($this->input->getOption('connection')) {
         $connection = $this->input->getOption('connection');
     }
     $config = ConnectionManager::config($connection);
     return $this->configuration = new Config(['paths' => ['migrations' => $dir], 'environments' => ['default_migration_table' => $plugin . 'phinxlog', 'default_database' => 'default', 'default' => ['adapter' => $this->getAdapterName($config['driver']), 'host' => isset($config['host']) ? $config['host'] : null, 'user' => isset($config['username']) ? $config['username'] : null, 'pass' => isset($config['password']) ? $config['password'] : null, 'port' => isset($config['port']) ? $config['port'] : null, 'name' => $config['database'], 'charset' => $config['encoding']]]]);
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:33,代码来源:ConfigurationTrait.php

示例4: getConfig

 /**
  * Overrides the original method from phinx in order to return a tailored
  * Config object containing the connection details for the database.
  *
  * @param bool $forceRefresh
  * @return \Phinx\Config\Config
  */
 public function getConfig($forceRefresh = false)
 {
     if ($this->configuration && $forceRefresh === false) {
         return $this->configuration;
     }
     $folder = 'Migrations';
     if ($this->input->getOption('source')) {
         $folder = $this->input->getOption('source');
     }
     $dir = ROOT . DS . 'config' . DS . $folder;
     $plugin = null;
     if ($this->input->getOption('plugin')) {
         $plugin = $this->input->getOption('plugin');
         $dir = Plugin::path($plugin) . 'config' . DS . $folder;
     }
     if (!is_dir($dir)) {
         mkdir($dir, 0777, true);
     }
     $plugin = $plugin ? Inflector::underscore($plugin) . '_' : '';
     $plugin = str_replace(['\\', '/', '.'], '_', $plugin);
     $connection = $this->getConnectionName($this->input);
     $connectionConfig = ConnectionManager::config($connection);
     $adapterName = $this->getAdapterName($connectionConfig['driver']);
     $config = ['paths' => ['migrations' => $dir], 'environments' => ['default_migration_table' => $plugin . 'phinxlog', 'default_database' => 'default', 'default' => ['adapter' => $adapterName, 'host' => isset($connectionConfig['host']) ? $connectionConfig['host'] : null, 'user' => isset($connectionConfig['username']) ? $connectionConfig['username'] : null, 'pass' => isset($connectionConfig['password']) ? $connectionConfig['password'] : null, 'port' => isset($connectionConfig['port']) ? $connectionConfig['port'] : null, 'name' => $connectionConfig['database'], 'charset' => isset($connectionConfig['encoding']) ? $connectionConfig['encoding'] : null, 'unix_socket' => isset($connectionConfig['unix_socket']) ? $connectionConfig['unix_socket'] : null]]];
     if ($adapterName === 'mysql') {
         if (!empty($connectionConfig['ssl_key']) && !empty($connectionConfig['ssl_cert'])) {
             $config['environments']['default']['mysql_attr_ssl_key'] = $connectionConfig['ssl_key'];
             $config['environments']['default']['mysql_attr_ssl_cert'] = $connectionConfig['ssl_cert'];
         }
         if (!empty($connectionConfig['ssl_ca'])) {
             $config['environments']['default']['mysql_attr_ssl_ca'] = $connectionConfig['ssl_ca'];
         }
     }
     return $this->configuration = new Config($config);
 }
开发者ID:JoHein,项目名称:LeBonCoup,代码行数:42,代码来源:ConfigurationTrait.php

示例5: getConfig

 /**
  * Overrides the original method from phinx in order to return a tailored
  * Config object containing the connection details for the database.
  *
  * @param bool $forceRefresh
  * @return \Phinx\Config\Config
  */
 public function getConfig($forceRefresh = false)
 {
     if ($this->configuration && $forceRefresh === false) {
         return $this->configuration;
     }
     $migrationsPath = $this->getOperationsPath($this->input);
     $seedsPath = $this->getOperationsPath($this->input, 'Seeds');
     $plugin = $this->getPlugin($this->input);
     if (!is_dir($migrationsPath)) {
         mkdir($migrationsPath, 0777, true);
     }
     if (!is_dir($seedsPath)) {
         mkdir($seedsPath, 0777, true);
     }
     $phinxTable = $this->getPhinxTable($plugin);
     $connection = $this->getConnectionName($this->input);
     $connectionConfig = ConnectionManager::config($connection);
     $adapterName = $this->getAdapterName($connectionConfig['driver']);
     $config = ['paths' => ['migrations' => $migrationsPath, 'seeds' => $seedsPath], 'environments' => ['default_migration_table' => $phinxTable, 'default_database' => 'default', 'default' => ['adapter' => $adapterName, 'host' => isset($connectionConfig['host']) ? $connectionConfig['host'] : null, 'user' => isset($connectionConfig['username']) ? $connectionConfig['username'] : null, 'pass' => isset($connectionConfig['password']) ? $connectionConfig['password'] : null, 'port' => isset($connectionConfig['port']) ? $connectionConfig['port'] : null, 'name' => $connectionConfig['database'], 'charset' => isset($connectionConfig['encoding']) ? $connectionConfig['encoding'] : null, 'unix_socket' => isset($connectionConfig['unix_socket']) ? $connectionConfig['unix_socket'] : null]]];
     if ($adapterName === 'pgsql') {
         if (!empty($connectionConfig['schema'])) {
             $config['environments']['default']['schema'] = $connectionConfig['schema'];
         }
     }
     if ($adapterName === 'mysql') {
         if (!empty($connectionConfig['ssl_key']) && !empty($connectionConfig['ssl_cert'])) {
             $config['environments']['default']['mysql_attr_ssl_key'] = $connectionConfig['ssl_key'];
             $config['environments']['default']['mysql_attr_ssl_cert'] = $connectionConfig['ssl_cert'];
         }
         if (!empty($connectionConfig['ssl_ca'])) {
             $config['environments']['default']['mysql_attr_ssl_ca'] = $connectionConfig['ssl_ca'];
         }
     }
     return $this->configuration = new Config($config);
 }
开发者ID:olafthelofty,项目名称:carenta,代码行数:42,代码来源:ConfigurationTrait.php

示例6: testWithPreMadeConnection

 public function testWithPreMadeConnection()
 {
     ConnectionManager::config('default', ['className' => 'Cake\\Database\\Connection', 'driver' => 'Cake\\Database\\Driver\\Sqlite']);
     $module = new CakeDbModule('default');
     $instance = (new Injector($module, $_ENV['TMP_DIR']))->getInstance('Cake\\Database\\Connection');
     $this->assertSame(ConnectionManager::get('default'), $instance);
 }
开发者ID:kumamidori,项目名称:Ray.CakeDbModule,代码行数:7,代码来源:CakeDbModuleTest.php

示例7: __construct

 public function __construct()
 {
     $config = ['className' => 'Cake\\Database\\Connection', 'driver' => 'Cake\\Database\\Driver\\Mysql', 'database' => Configure::get('database.database'), 'username' => Configure::get('database.username'), 'password' => Configure::get('database.password'), 'host' => Configure::get('database.host'), 'persistent' => Configure::get('database.persistant'), 'encoding' => Configure::get('database.encoding'), 'timezone' => Configure::get('database.timezone'), 'quoteIdentifiers' => Configure::get('database.quoteIdentifiers'), 'log' => Configure::get('database.log')];
     ConnectionManager::config('default', $config);
     $link = ConnectionManager::get('default');
     self::$_logger = new QueryLogger();
     $link->logger(self::$_logger);
 }
开发者ID:NuBOXDevCom,项目名称:frambox-core,代码行数:8,代码来源:Orm.php

示例8: setUp

 protected function setUp()
 {
     parent::setUp();
     $configured = ConnectionManager::configured();
     if (empty($configured)) {
         ConnectionManager::config('default', ['className' => 'Cake\\Database\\Connection', 'driver' => 'Cake\\Database\\Driver\\Sqlite', 'database' => self::SQLITE_PATH]);
     }
     $this->Posts = TableRegistry::get('Posts');
 }
开发者ID:alexdpy,项目名称:acl,代码行数:9,代码来源:CakephpOrmAclFilterTest.php

示例9: getMaxNo

 public function getMaxNo($restaurantId)
 {
     $datasource = ConnectionManager::config('default');
     $connection = mysql_connect($datasource['host'], $datasource['username'], $datasource['password']);
     mysql_select_db($datasource['database'], $connection);
     $query = "call RestaurantDB.getMaxTakeawayNo(" . $restaurantId . ", @takawaymaxno);";
     $result = mysql_query($query);
     $data = mysql_fetch_assoc($result);
     mysql_close($connection);
     return $data['maxId'];
 }
开发者ID:Vibeosys,项目名称:RorderWeb,代码行数:11,代码来源:TakeawayTable.php

示例10: __construct

 /**
  * Union migrate manager constructor.
  *
  * @param null $plugin
  */
 public function __construct($plugin = null)
 {
     if (Plugin::loaded($plugin)) {
         $this->_connectionConfig = ConnectionManager::config($this->_connectionName);
         $this->_adapterName = $this->_getAdapterName($this->_connectionConfig['driver']);
         $config = ['paths' => ['migrations' => UnionPlugin::migrationPath($plugin)], 'environments' => $this->_configuration()];
         $this->_plugin = $plugin;
         $this->_config = new Config($config);
         $adapterOptions = $this->_config->getEnvironment($this->_connectionName);
         $this->_adapter = $this->_setAdapter($adapterOptions);
     }
 }
开发者ID:Cheren,项目名称:union,代码行数:17,代码来源:UnionManager.php

示例11: get_product_list

 public function get_product_list()
 {
     // make array with value is offeritems_id and text show from product table
     ConnectionManager::config('default');
     $conn = ConnectionManager::get('default');
     $product_list = $conn->query("SELECT OfferItems.id AS `OfferItems__id`, Products.productName AS `Products__productName`" . " FROM offer_items OfferItems INNER JOIN order_items OrderItems ON OrderItems.id = (OfferItems.order_items_id)" . " INNER JOIN products Products ON Products.id = (OrderItems.products_id) LIMIT 20 OFFSET 0");
     $offerItem_product_list = [];
     foreach ($product_list as $prod) {
         $offerItem_product_list[$prod['OfferItems__id']] = $prod['Products__productName'];
     }
     return $offerItem_product_list;
 }
开发者ID:ahsankhan201,项目名称:trade,代码行数:12,代码来源:CunsignmentItemsTable.php

示例12: startup

 /**
  * {@inheritdoc}
  */
 public function startup()
 {
     foreach (Config::get('cake_orm.datasources', []) as $name => $dataSource) {
         ConnectionManager::config($name, $dataSource);
     }
     Cache::config(Config::get('cake_orm.cache', []));
     if (!is_dir($cakeLogPath = LOG_DIR . DS . 'cake')) {
         mkdir($cakeLogPath, 0777, true);
     }
     Log::config('queries', ['className' => 'File', 'path' => LOG_DIR . DS . 'cake' . DS, 'file' => 'queries.log', 'scopes' => ['queriesLog']]);
     $this->getEventManager()->addSubscriber(new CakeORMSubscriber());
 }
开发者ID:radphp,项目名称:cake-orm-bundle,代码行数:15,代码来源:CakeOrmBundle.php

示例13: initialize

 function initialize(Container $container)
 {
     parent::initialize($container);
     $configs = $this->getConfigs();
     // 设置数据库
     foreach ($configs['datasources'] as $name => $config) {
         ConnectionManager::config($name, $config);
     }
     // 设置缓存
     foreach ($configs['cache'] as $name => $config) {
         Cache::config($name, $config);
     }
 }
开发者ID:slince,项目名称:cake-bridge,代码行数:13,代码来源:CakeBridge.php

示例14: testInvalidDB

 public function testInvalidDB()
 {
     $this->setExpectedException('Chris48s\\Searchable\\Exception\\SearchableFatalException');
     //set up a SQLite DB connection - SQLite is not supported
     ConnectionManager::config('invalid', ['url' => 'sqlite:///:memory:', 'timezone' => 'UTC']);
     $conn = ConnectionManager::get('invalid');
     //create a table in SQLite
     $conn->query("CREATE TABLE `Foo` (\n            `id` int(11) NOT NULL,\n            `textcol` VARCHAR(255),\n            PRIMARY KEY (`id`)\n        );");
     $table = TableRegistry::get('Foo', ['connection' => $conn]);
     $table->addBehavior('Chris48s/Searchable.Searchable');
     //tidy up
     ConnectionManager::dropAlias('invalid');
 }
开发者ID:chris48s,项目名称:cakephp-searchable,代码行数:13,代码来源:SearchableBehaviorTest.php

示例15: get_related_products

 public static function get_related_products($parent_id, $product_id)
 {
     ConnectionManager::config('default');
     $conn = ConnectionManager::get('default');
     /* $product_list = $conn->query("SELECT products.*, product_makers.products_id As ProdMakerId FROM products
        INNER JOIN
        product_makers ON product_makers.id = products.product_makers_id
        WHERE
        product_makers.users_id = (SELECT product_makers.users_id AS MakerID FROM products 
        LEFT JOIN 
        product_makers ON product_makers.id = products.product_makers_id 
        WHERE 
        products.id = '" . $product_id . "') AND products.id != '" . $product_id . "'"); */
     $product_list = $conn->query("SELECT products.* FROM products WHERE products.id != '" . $product_id . "'" . " AND products.categoreys_id IN((" . "SELECT categoreys.id FROM categoreys WHERE categoreys.parent_id =(" . "SELECT categoreys.parent_id FROM categoreys WHERE categoreys.id= '" . $parent_id . "')))");
     return $product_list;
 }
开发者ID:ahsankhan201,项目名称:trade,代码行数:16,代码来源:ProductsTable.php


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