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


PHP Connections::add方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     $this->_handlers = array('id' => function ($v) {
         return is_string($v) && preg_match('/^[0-9a-f]{24}$/', $v) ? new MongoId($v) : $v;
     }, 'date' => function ($v) {
         $v = is_numeric($v) ? (int) $v : strtotime($v);
         return !$v ? new MongoDate() : new MongoDate($v);
     }, 'regex' => function ($v) {
         return new MongoRegex($v);
     }, 'integer' => function ($v) {
         return (int) $v;
     }, 'float' => function ($v) {
         return (double) $v;
     }, 'boolean' => function ($v) {
         return (bool) $v;
     }, 'code' => function ($v) {
         return new MongoCode($v);
     }, 'binary' => function ($v) {
         return new MongoBinData($v);
     });
     $model = $this->_model;
     Connections::add('mockconn', array('object' => new MongoDb(array('autoConnect' => false))));
     $model::config(array('meta' => array('connection' => 'mockconn')));
     $model::schema(false);
     $model::schema($this->_schema);
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:26,代码来源:ExporterTest.php

示例2: testStreamConnection

 public function testStreamConnection()
 {
     $config = array('socket' => 'Stream', 'host' => 'localhost', 'login' => 'root', 'password' => '', 'port' => '80');
     Connections::add('stream-test', 'Http', $config);
     $result = Connections::get('stream-test');
     $this->assertTrue($result instanceof \lithium\data\source\Http);
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:7,代码来源:ConnectionsTest.php

示例3: setUp

 public function setUp()
 {
     Connections::add('mockconn', array('object' => new MockSource()));
     $schema = new Schema(array('fields' => array('id' => 'int', 'title' => 'string', 'body' => 'text')));
     MockPost::config(array('meta' => array('connection' => 'mockconn', 'key' => 'id', 'locked' => true), 'schema' => $schema));
     $this->_record = new Record(array('model' => 'lithium\\tests\\mocks\\data\\MockPost'));
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:7,代码来源:RecordTest.php

示例4: setUp

 public function setUp()
 {
     $this->_db = new MockDatabase();
     Connections::add('mockconn', array('object' => $this->_db));
     MockGallery::config(array('meta' => array('connection' => 'mockconn')));
     MockImage::config(array('meta' => array('connection' => 'mockconn')));
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:7,代码来源:RelationshipTest.php

示例5: tearDown

 /**
  * Teardown method run after every test method.
  */
 public function tearDown()
 {
     Connections::reset();
     foreach ($this->_backup as $name => $config) {
         Connections::add($name, $config);
     }
 }
开发者ID:nashadalam,项目名称:lithium,代码行数:10,代码来源:CollectionTest.php

示例6: setUp

 public function setUp()
 {
     Connections::add('test-gh', array('type' => 'http', 'adapter' => 'GitHub', 'login' => '', 'password' => '', 'socket' => 'li3_github\\tests\\mocks\\MockGitHubSocket'));
     Issues::config(array('connection' => 'test-gh'));
     Repos::config(array('connection' => 'test-gh'));
     Users::config(array('connection' => 'test-gh'));
     Orgs::config(array('connection' => 'test-gh'));
 }
开发者ID:notomato,项目名称:li3_github,代码行数:8,代码来源:GitHubTest.php

示例7: testConnectWithWrongPassword

 public function testConnectWithWrongPassword()
 {
     $config = $this->_dbConfig;
     $config['login'] = 'wrong_login';
     $config['password'] = 'wrong_pass';
     $connection = 'wrong_passord';
     Connections::add($connection, $config);
     $this->expectException('/Host connected, but could not access database/');
     Connections::get($connection)->connect();
 }
开发者ID:davidpersson,项目名称:FrameworkBenchmarks,代码行数:10,代码来源:DatabaseTest.php

示例8: setUp

 public function setUp()
 {
     $this->_backup['cwd'] = getcwd();
     $this->_backup['_SERVER'] = $_SERVER;
     $_SERVER['argv'] = array();
     Libraries::add('create_test', array('path' => $this->_testPath . '/create_test'));
     $this->request = new Request(array('input' => fopen('php://temp', 'w+')));
     $this->request->params = array('library' => 'create_test', 'action' => null);
     Connections::add('default', array('type' => null, 'adapter' => 'lithium\\tests\\mocks\\data\\model\\MockDatabase'));
 }
开发者ID:davidpersson,项目名称:FrameworkBenchmarks,代码行数:10,代码来源:CreateTest.php

示例9: add

 /**
  * 添加数据库链接
  * @param string $name 名称
  * @param array $config 配置
  * @param bool $overwrite 是否覆盖已有配置,默认否
  * @return array
  */
 public static function add($name, array $config = array(), $overwrite = false)
 {
     if ($overwrite) {
         parent::add($name, $config);
     } else {
         if (!isset(static::$_configurations[$name])) {
             parent::add($name, $config);
         }
     }
     return static::$_configurations[$name];
 }
开发者ID:qujian,项目名称:rwe,代码行数:18,代码来源:Connections.php

示例10: setUp

 public function setUp()
 {
     $this->_db = new CouchDb(array('socket' => false));
     $model = $this->_model;
     Connections::add('mockconn', array('object' => $this->_db));
     $model::config(array('meta' => array('connection' => 'mockconn')));
     $model::resetSchema();
     $entity = new Document(compact('model'));
     $type = 'create';
     $this->_query = new Query(compact('model', 'entity', 'type'));
 }
开发者ID:rapzo,项目名称:lithium,代码行数:11,代码来源:CouchDbTest.php

示例11: testConnectWithWrongPassword

 public function testConnectWithWrongPassword()
 {
     $this->skipIf(!$this->with('PostgreSql'));
     $config = $this->_dbConfig;
     $config['login'] = 'wrong_login';
     $config['password'] = 'wrong_pass';
     $config['object'] = null;
     $connection = 'wrong_passord';
     Connections::add($connection, $config);
     $this->expectException();
     Connections::get($connection)->connect();
 }
开发者ID:rapzo,项目名称:lithium,代码行数:12,代码来源:DatabaseTest.php

示例12: setUp

 public function setUp()
 {
     $this->_db = new MockDatabase();
     Connections::add('mockconn', array('object' => $this->_db));
     $config = array('meta' => array('connection' => 'mockconn'));
     MockQueryPost::config($config);
     MockQueryComment::config($config);
     MockGallery::config($config);
     MockImage::config($config);
     MockImageTag::config($config);
     MockTag::config($config);
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:12,代码来源:QueryTest.php

示例13: testErrorExceptions

 public function testErrorExceptions()
 {
     $config = array('adapter' => 'None', 'type' => 'Error');
     Connections::add('NoConnection', $config);
     $result = false;
     try {
         Connections::get('NoConnection');
     } catch (Exception $e) {
         $result = true;
     }
     $this->assertTrue($result, 'Exception is not thrown');
 }
开发者ID:rmarscher,项目名称:lithium,代码行数:12,代码来源:ConnectionsTest.php

示例14: setUp

 public function setUp()
 {
     Connections::add('mocksource', array('object' => new MockSource()));
     Connections::add('mockconn', array('object' => new MockDatabase()));
     MockPost::config(array('meta' => array('connection' => 'mocksource')));
     MockTag::config(array('meta' => array('connection' => 'mocksource')));
     MockComment::config(array('meta' => array('connection' => 'mocksource')));
     MockCreator::config(array('meta' => array('connection' => 'mocksource')));
     MockSubProduct::config(array('meta' => array('connection' => 'mockconn')));
     MockProduct::config(array('meta' => array('connection' => 'mockconn')));
     MockPostForValidates::config(array('meta' => array('connection' => 'mockconn')));
     $this->_altSchema = new Schema(array('fields' => array('id' => array('type' => 'integer'), 'author_id' => array('type' => 'integer'), 'title' => array('type' => 'string'), 'body' => array('type' => 'text'))));
 }
开发者ID:rapzo,项目名称:lithium,代码行数:13,代码来源:ModelTest.php

示例15: setUp

 public function setUp()
 {
     $connection = new MockDocumentSource();
     Connections::add('mockconn', array('object' => $connection));
     MockDocumentPost::config(array('meta' => array('connection' => 'mockconn')));
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:6,代码来源:DocumentSetTest.php


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