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


PHP Resource::getConnection方法代码示例

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


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

示例1: loadLogData

 /**
  * Load customer log data by customer id
  *
  * @param int $customerId
  * @return array
  */
 protected function loadLogData($customerId)
 {
     /** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */
     $connection = $this->resource->getConnection();
     $select = $connection->select()->from(['cl' => $this->resource->getTableName('customer_log')])->joinLeft(['cv' => $this->resource->getTableName('customer_visitor')], 'cv.customer_id = cl.customer_id', ['last_visit_at'])->where('cl.customer_id = ?', $customerId)->order('cv.visitor_id DESC')->limit(1);
     return $connection->fetchRow($select);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:Logger.php

示例2: _getConnection

 /**
  * Retrieve write connection instance
  *
  * @return bool|\Magento\Framework\DB\Adapter\AdapterInterface
  */
 protected function _getConnection()
 {
     if (null === $this->_connection) {
         $this->_connection = $this->_resource->getConnection();
     }
     return $this->_connection;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:RefreshSpecialPrices.php

示例3: __construct

 /**
  * @param ResourceConnection $resource
  * @param string $targetColumn
  * @param string $targetTable
  * @param array $referenceColumns
  * @param array $sortOrder
  */
 public function __construct(ResourceConnection $resource, $targetColumn, $targetTable, array $referenceColumns = [], array $sortOrder = [])
 {
     $this->targetTable = $targetTable;
     $this->targetColumn = $targetColumn;
     $this->referenceColumns = $referenceColumns;
     $this->sortOrder = $sortOrder;
     $this->resource = $resource;
     $this->adapter = $this->resource->getConnection();
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:16,代码来源:LookupExpression.php

示例4: getCustomerIdsForReindex

 /**
  * Retrieve customer IDs for reindex
  *
  * @return array
  */
 protected function getCustomerIdsForReindex()
 {
     $connection = $this->resource->getConnection();
     $gridTableName = $this->flatScopeResolver->resolve(Customer::CUSTOMER_GRID_INDEXER_ID, []);
     $select = $connection->select()->from($this->resource->getTableName($gridTableName), 'last_visit_at')->order('last_visit_at DESC')->limit(1);
     $lastVisitAt = $connection->query($select)->fetchColumn();
     $select = $connection->select()->from($this->resource->getTableName('customer_log'), 'customer_id')->where('last_login_at > ?', $lastVisitAt);
     $customerIds = [];
     foreach ($connection->query($select)->fetchAll() as $row) {
         $customerIds[] = $row['customer_id'];
     }
     return $customerIds;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:Grid.php

示例5: build

 /**
  * Build index query
  *
  * @param RequestInterface $request
  * @return Select
  */
 public function build(RequestInterface $request)
 {
     $searchIndexTable = $this->scopeResolver->resolve($request->getIndex(), $request->getDimensions());
     $select = $this->resource->getConnection()->select()->from(['search_index' => $searchIndexTable], ['entity_id' => 'entity_id'])->joinLeft(['cea' => $this->resource->getTableName('catalog_eav_attribute')], 'search_index.attribute_id = cea.attribute_id', []);
     $select = $this->tableMapper->addTables($select, $request);
     $select = $this->processDimensions($request, $select);
     $isShowOutOfStock = $this->config->isSetFlag('cataloginventory/options/show_out_of_stock', ScopeInterface::SCOPE_STORE);
     if ($isShowOutOfStock === false) {
         $select->joinLeft(['stock_index' => $this->resource->getTableName('cataloginventory_stock_status')], 'search_index.entity_id = stock_index.product_id' . $this->resource->getConnection()->quoteInto(' AND stock_index.website_id = ?', $this->storeManager->getWebsite()->getId()), []);
         $select->where('stock_index.stock_status = ?', 1);
     }
     return $select;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:IndexBuilder.php

示例6: filter

 /**
  * @param array $attributes
  * @return array
  */
 public function filter(array $attributes)
 {
     $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
     if ($indexer->getState()->getStatus() != StateInterface::STATUS_VALID) {
         $tableName = $this->flatScopeResolver->resolve(Customer::CUSTOMER_GRID_INDEXER_ID, []);
         $columns = $this->resource->getConnection()->describeTable($tableName);
         foreach (array_keys($attributes) as $attributeCode) {
             if (!isset($columns[$attributeCode])) {
                 unset($attributes[$attributeCode]);
             }
         }
     }
     return $attributes;
 }
开发者ID:IlyaGluschenko,项目名称:protection,代码行数:18,代码来源:Filter.php

示例7: validate

 /**
  * Check attribute lock state
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @param null $attributeSet
  * @throws \Magento\Framework\Exception\LocalizedException
  * @return void
  */
 public function validate(\Magento\Framework\Model\AbstractModel $object, $attributeSet = null)
 {
     $metadata = $this->metadataPool->getMetadata(ProductInterface::class);
     $connection = $this->resource->getConnection();
     $bind = ['attribute_id' => $object->getAttributeId()];
     $select = clone $connection->select();
     $select->reset()->from(['main_table' => $this->resource->getTableName('catalog_product_super_attribute')], ['psa_count' => 'COUNT(product_super_attribute_id)'])->join(['entity' => $this->resource->getTableName('catalog_product_entity')], 'main_table.product_id = entity.' . $metadata->getLinkField())->where('main_table.attribute_id = :attribute_id')->group('main_table.attribute_id')->limit(1);
     if ($attributeSet !== null) {
         $bind['attribute_set_id'] = $attributeSet;
         $select->where('entity.attribute_set_id = :attribute_set_id');
     }
     if ($connection->fetchOne($select, $bind)) {
         throw new \Magento\Framework\Exception\LocalizedException(__('This attribute is used in configurable products.'));
     }
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:23,代码来源:LockValidator.php

示例8: insertDocuments

 /**
  * @param array $documents
  * @param Dimension[] $dimensions
  * @return void
  */
 private function insertDocuments(array $documents, array $dimensions)
 {
     $documents = $this->prepareSearchableFields($documents);
     if (empty($documents)) {
         return;
     }
     $this->resource->getConnection()->insertOnDuplicate($this->getTableName($dimensions), $documents, ['data_index']);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:IndexerHandler.php

示例9: aroundGetDataSet

 /**
  * @param \Magento\CatalogSearch\Model\Adapter\Mysql\Aggregation\DataProvider $subject
  * @param callable|\Closure $proceed
  * @param BucketInterface $bucket
  * @param Dimension[] $dimensions
  *
  * @param Table $entityIdsTable
  * @return Select
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundGetDataSet(\Magento\CatalogSearch\Model\Adapter\Mysql\Aggregation\DataProvider $subject, \Closure $proceed, BucketInterface $bucket, array $dimensions, Table $entityIdsTable)
 {
     if ($bucket->getField() == 'category_ids') {
         $currentScopeId = $this->scopeResolver->getScope($dimensions['scope']->getValue())->getId();
         $currentCategory = $this->layer->getCurrentCategory();
         $derivedTable = $this->resource->getConnection()->select();
         $derivedTable->from(['main_table' => $this->resource->getTableName('catalog_category_product_index')], ['value' => 'category_id'])->where('main_table.store_id = ?', $currentScopeId);
         $derivedTable->joinInner(['entities' => $entityIdsTable->getName()], 'main_table.product_id  = entities.entity_id', []);
         if (!empty($currentCategory)) {
             $derivedTable->join(['category' => $this->resource->getTableName('catalog_category_entity')], 'main_table.category_id = category.entity_id', [])->where('`category`.`path` LIKE ?', $currentCategory->getPath() . '%')->where('`category`.`level` > ?', $currentCategory->getLevel());
         }
         $select = $this->resource->getConnection()->select();
         $select->from(['main_table' => $derivedTable]);
         return $select;
     }
     return $proceed($bucket, $dimensions, $entityIdsTable);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:27,代码来源:DataProvider.php

示例10: getConnection

 /**
  * Retrieve connection to resource specified by $resourceName.
  *
  * @param string $resourceName
  * @return \Exception|false|\Magento\Framework\DB\Adapter\AdapterInterface|\Zend_Exception
  */
 protected function getConnection($resourceName)
 {
     try {
         $connection = $this->resource->getConnection($resourceName);
         return $connection;
     } catch (\Zend_Exception $e) {
         echo $e->getMessage() . PHP_EOL;
         return $e;
     }
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:16,代码来源:FieldsProvider.php

示例11: createFlatIndex

 /**
  * @param string $tableName
  * @param array $fields
  * @throws \Zend_Db_Exception
  * @return void
  */
 protected function createFlatIndex($tableName, array $fields)
 {
     $table = $this->resource->getConnection()->newTable($tableName);
     $table->addColumn('entity_id', Table::TYPE_INTEGER, 10, ['unsigned' => true, 'nullable' => false], 'Entity ID');
     foreach ($fields as $field) {
         if ($field['type'] !== 'filterable') {
             continue;
         }
         $columnMap = isset($field['dataType']) && isset($this->columnTypesMap[$field['dataType']]) ? $this->columnTypesMap[$field['dataType']] : ['type' => $field['type'], 'size' => isset($field['size']) ? $field['size'] : null];
         $name = $field['name'];
         $type = $columnMap['type'];
         $size = $columnMap['size'];
         $table->addColumn($name, $type, $size);
     }
     $this->resource->getConnection()->createTable($table);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:22,代码来源:IndexStructure.php

示例12: getFieldToTableMap

 /**
  * @param string $field
  * @return array|null
  */
 private function getFieldToTableMap($field)
 {
     $fieldToTableMap = ['price' => ['price_index', 'catalog_product_index_price', $this->resource->getConnection()->quoteInto('search_index.entity_id = price_index.entity_id AND price_index.website_id = ?', $this->getWebsiteId()), []], 'category_ids' => ['category_ids_index', 'catalog_category_product_index', 'search_index.entity_id = category_ids_index.product_id', []]];
     return array_key_exists($field, $fieldToTableMap) ? $fieldToTableMap[$field] : null;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:TableMapper.php

示例13: getConnection

 /**
  * Get Connection
  *
  * @return AdapterInterface
  */
 private function getConnection()
 {
     return $this->resource->getConnection();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:9,代码来源:Builder.php

示例14: getAdapter

 /**
  * @return false|AdapterInterface
  */
 private function getAdapter()
 {
     $adapter = $this->resource->getConnection('write');
     return $adapter;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:GridStructure.php

示例15: createFulltextIndex

 /**
  * @param string $tableName
  * @throws \Zend_Db_Exception
  * @return void
  */
 protected function createFulltextIndex($tableName)
 {
     $table = $this->resource->getConnection()->newTable($tableName)->addColumn('entity_id', Table::TYPE_INTEGER, 10, ['unsigned' => true, 'nullable' => false], 'Entity ID')->addColumn('attribute_id', Table::TYPE_INTEGER, 10, ['unsigned' => true, 'nullable' => false])->addColumn('data_index', Table::TYPE_TEXT, '4g', ['nullable' => true], 'Data index')->addIndex('idx_primary', ['entity_id', 'attribute_id'], ['type' => AdapterInterface::INDEX_TYPE_PRIMARY])->addIndex('FTI_FULLTEXT_DATA_INDEX', ['data_index'], ['type' => AdapterInterface::INDEX_TYPE_FULLTEXT]);
     $this->resource->getConnection()->createTable($table);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:IndexStructure.php


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