當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AbstractDb::getReadConnection方法代碼示例

本文整理匯總了PHP中Magento\Framework\Model\Resource\Db\AbstractDb::getReadConnection方法的典型用法代碼示例。如果您正苦於以下問題:PHP AbstractDb::getReadConnection方法的具體用法?PHP AbstractDb::getReadConnection怎麽用?PHP AbstractDb::getReadConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Model\Resource\Db\AbstractDb的用法示例。


在下文中一共展示了AbstractDb::getReadConnection方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetConnectionInMemoryCaching

 /**
  * Test that the model detects a connection when it becomes active
  */
 public function testGetConnectionInMemoryCaching()
 {
     $string = $this->getMock('Magento\\Framework\\Stdlib\\String', [], [], '', false);
     $dateTime = $this->getMock('Magento\\Framework\\Stdlib\\DateTime', null, [], '', true);
     $logger = $this->getMockForAbstractClass('Magento\\Framework\\DB\\LoggerInterface');
     $connection = new \Magento\Framework\DB\Adapter\Pdo\Mysql($string, $dateTime, $logger, ['dbname' => 'test_dbname', 'username' => 'test_username', 'password' => 'test_password']);
     $this->_resource->expects($this->atLeastOnce())->method('getConnection')->with('core_read')->will($this->onConsecutiveCalls(false, $connection, false));
     $this->assertFalse($this->_model->getReadConnection());
     $this->assertSame($connection, $this->_model->getReadConnection(), 'Inactive connection should not be cached');
     $this->assertSame($connection, $this->_model->getReadConnection(), 'Active connection should be cached');
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:14,代碼來源:AbstractTest.php

示例2: testGetReadAdapter

 public function testGetReadAdapter()
 {
     $adapterInterfaceMock = $this->getMock('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface', [], [], '', false);
     $adapterInterfaceMock->expects($this->once())->method('getTransactionLevel')->will($this->returnValue(1));
     $this->_resourcesMock->expects($this->any())->method('getConnection')->will($this->returnValue($adapterInterfaceMock));
     $this->assertInstanceOf('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface', $this->_model->getReadConnection());
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:7,代碼來源:AbstractDbTest.php

示例3: getFulltextIndexColumns

 /**
  * Returns list of columns from fulltext index (doesn't support more then one FTI per table)
  *
  * @param DbResource $resource
  * @param string $indexTable
  * @return array
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function getFulltextIndexColumns(DbResource $resource, $indexTable)
 {
     $indexes = $resource->getReadConnection()->getIndexList($indexTable);
     foreach ($indexes as $index) {
         if (strtoupper($index['INDEX_TYPE']) == 'FULLTEXT') {
             return $index['COLUMNS_LIST'];
         }
     }
     return [];
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:18,代碼來源:FulltextFilter.php


注:本文中的Magento\Framework\Model\Resource\Db\AbstractDb::getReadConnection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。