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


PHP ConnectionManager::getDatasource方法代码示例

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


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

示例1: setUp

 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $db = ConnectionManager::getDatasource('test');
     $db->fullDebug = true;
     Configure::write('Cache.disable', false);
     Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
     Router::parse('/');
     $this->Controller = new Controller(null);
     $this->View = new View($this->Controller);
     $this->Toolbar = new ToolbarHelper($this->View, array('output' => 'MockBackendHelper', 'cacheKey' => 'debug_kit_toolbar_test_case', 'cacheConfig' => 'default'));
     $this->Toolbar->MockBackend = $this->getMock('Helper', array('testMethod'), array($this->View));
     $this->_viewPaths = App::path('views');
     App::build(array('View' => array(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Test' . DS . 'test_app' . DS . 'View' . DS, APP . 'Plugin' . DS . 'DebugKit' . DS . 'View' . DS, CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'View' . DS)), true);
 }
开发者ID:hupla78,项目名称:Nadia,代码行数:20,代码来源:ToolbarHelperTest.php

示例2: testTruncateStatements

 /**
  * Test truncate with a mock.
  *
  * @return void
  */
 public function testTruncateStatements()
 {
     $this->loadFixtures('Article', 'User');
     $db = ConnectionManager::getDatasource('test');
     $schema = $db->config['schema'];
     $Article = new Article();
     $this->Dbo = $this->getMock('Postgres', array('execute'), array($db->config));
     $this->Dbo->expects($this->at(0))->method('execute')->with("DELETE FROM \"{$schema}\".\"articles\"");
     $this->Dbo->truncate($Article);
     $this->Dbo->expects($this->at(0))->method('execute')->with("DELETE FROM \"{$schema}\".\"articles\"");
     $this->Dbo->truncate('articles');
     // #2355: prevent duplicate prefix
     $this->Dbo->config['prefix'] = 'tbl_';
     $Article->tablePrefix = 'tbl_';
     $this->Dbo->expects($this->at(0))->method('execute')->with("DELETE FROM \"{$schema}\".\"tbl_articles\"");
     $this->Dbo->truncate($Article);
     $this->Dbo->expects($this->at(0))->method('execute')->with("DELETE FROM \"{$schema}\".\"tbl_articles\"");
     $this->Dbo->truncate('articles');
 }
开发者ID:jeffersongoncalves,项目名称:estudos,代码行数:24,代码来源:PostgresTest.php

示例3: testTruncateStatements

 /**
  * Test truncate with a mock.
  *
  * @return void
  */
 public function testTruncateStatements()
 {
     $this->loadFixtures('Article', 'User');
     $db = ConnectionManager::getDatasource('test');
     $schema = $db->config['database'];
     $Article = new Article();
     $this->Dbo = $this->getMock('Mysql', array('execute'), array($db->config));
     $this->Dbo->expects($this->at(0))->method('execute')->with("TRUNCATE TABLE `{$schema}`.`articles`");
     $this->Dbo->truncate($Article);
     $this->Dbo->expects($this->at(0))->method('execute')->with("TRUNCATE TABLE `{$schema}`.`articles`");
     $this->Dbo->truncate('articles');
     // #2355: prevent duplicate prefix
     $this->Dbo->config['prefix'] = 'tbl_';
     $Article->tablePrefix = 'tbl_';
     $this->Dbo->expects($this->at(0))->method('execute')->with("TRUNCATE TABLE `{$schema}`.`tbl_articles`");
     $this->Dbo->truncate($Article);
     $this->Dbo->expects($this->at(0))->method('execute')->with("TRUNCATE TABLE `{$schema}`.`tbl_articles`");
     $this->Dbo->truncate('articles');
 }
开发者ID:laiello,项目名称:double-l-bookmanagement,代码行数:24,代码来源:MysqlTest.php

示例4: testDeleteStatements

 /**
  * Test deletes with a mock.
  *
  * @return void
  */
 public function testDeleteStatements()
 {
     $this->loadFixtures('Article', 'User');
     $test = ConnectionManager::getDatasource('test');
     $this->Dbo = $this->getMock('Mysql', array('execute'), array($test->config));
     $this->Dbo->expects($this->at(0))->method('execute')->with("DELETE  FROM `articles`  WHERE 1 = 1");
     $this->Dbo->expects($this->at(1))->method('execute')->with("DELETE `Article` FROM `articles` AS `Article` LEFT JOIN `users` AS `User` ON (`Article`.`user_id` = `User`.`id`)" . "  WHERE 1 = 1");
     $this->Dbo->expects($this->at(2))->method('execute')->with("DELETE `Article` FROM `articles` AS `Article` LEFT JOIN `users` AS `User` ON (`Article`.`user_id` = `User`.`id`)" . "  WHERE 2=2");
     $Article = new Article();
     $this->Dbo->delete($Article);
     $this->Dbo->delete($Article, true);
     $this->Dbo->delete($Article, '2=2');
 }
开发者ID:Chromedian,项目名称:inventory,代码行数:18,代码来源:MysqlTest.php

示例5: first_import

 /**
  * firstImport method
  *
  * accepts an xml dump (generated from the nodes controller admin_export function)
  * and contents with the file contents.
  *
  * @param mixed $xml
  * @return void
  * @access public
  */
 function first_import($xml, $options = array(), $thisUser = false)
 {
     $deleteFirst = true;
     $addingTranslation = false;
     extract($options);
     uses('Xml');
     $xml = new Xml($xml);
     $xml = Set::reverse($xml);
     $meta = Set::extract($xml, '/Contents/Meta');
     $nodes = Set::extract($xml, '/Contents/Node');
     $nodes = $nodes[0];
     $ids = Set::extract($nodes, '/Node/id');
     set_time_limit(count($ids) * 2);
     unset($this->Revision->validate['content']);
     if (Configure::read('Languages.default') != $meta[0]['Meta']['lang']) {
         $addingTranslation = true;
         if ($this->find('count') > 0) {
             $deleteFirst = false;
         }
     }
     $db =& ConnectionManager::getDataSouce($this->useDbConfig);
     $db->begin($this);
     if ($deleteFirst) {
         $db =& ConnectionManager::getDatasource('default');
         $db->query('truncate nodes');
         $db->query('truncate changes');
         $db->query('truncate revisions');
     }
     foreach ($nodes['Node'] as $i => $row) {
         extract($row);
         if ($addingTranslation && $Revision['lang'] == Configure::read('Languages.default')) {
             continue;
         }
         $parent_id = empty($parent_id) ? null : $parent_id;
         if (!$addingTranslation) {
             $depth = empty($depth) ? 0 : $depth;
             $show_in_toc = empty($show_in_toc) ? 0 : 1;
             $status = 1;
             $sequence = null;
             $toSave = compact('id', 'parent_id', 'depth', 'status', 'show_in_toc');
             if ($i == 0) {
                 $toSave['lft'] = 1;
                 $toSave['rght'] = 2;
             } else {
                 $toSave['lft'] = $parent_id;
                 $rght = $this->field('id', array('parent_id' => $id));
                 $toSave['rght'] = empty($rght) ? 0 : $rght;
             }
             $this->create();
             $this->id = false;
             if (!$this->save(array('Node' => $toSave), false)) {
                 $db->rallback($this);
                 return false;
             }
         }
         $toSave = $Revision;
         $toSave['reason'] = empty($toSave['reason']) || is_array($toSave['reason']) ? "" : $toSave['reason'];
         $toSave['content'] = empty($toSave['content']) || is_array($toSave['content']) ? "" : $toSave['content'];
         $toSave['node_id'] = $id;
         $toSave['under_node_id'] = $parent_id;
         $toSave['status'] = 'current';
         if ($thisUser) {
             $toSave['user_id'] = $thisUser;
         }
         $this->Revision->create();
         if (!$this->Revision->save(array('Revision' => $toSave), false)) {
             $db->rallback($this);
             return false;
         }
     }
     $db->commit($this);
     return true;
 }
开发者ID:hiromi2424,项目名称:cookbook,代码行数:83,代码来源:node.php

示例6: isAuthorized

 public function isAuthorized()
 {
     // set OAuth
     ConnectionManager::getDatasource('twitter')->setToken($this->Auth->user('oauth_token'), $this->Auth->user('oauth_token_secret'));
     return true;
 }
开发者ID:nojimage,项目名称:tiwt,代码行数:6,代码来源:app_controller.php


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