本文整理汇总了PHP中Magento\Framework\DB\Adapter\AdapterInterface::getTableName方法的典型用法代码示例。如果您正苦于以下问题:PHP AdapterInterface::getTableName方法的具体用法?PHP AdapterInterface::getTableName怎么用?PHP AdapterInterface::getTableName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\DB\Adapter\AdapterInterface
的用法示例。
在下文中一共展示了AdapterInterface::getTableName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
/** @var \Magento\Framework\Setup\ModuleDataSetupInterface $installer */
$installer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('\\Magento\\Framework\\Setup\\ModuleDataSetupInterface');
$this->_connection = $installer->getConnection();
$this->_tableName = $this->_connection->getTableName('table_two_column_idx');
$this->_oneColumnIdxName = $this->_connection->getIndexName($this->_tableName, ['column1']);
$this->_twoColumnIdxName = $this->_connection->getIndexName($this->_tableName, ['column1', 'column2']);
$table = $this->_connection->newTable($this->_tableName)->addColumn('id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'Id')->addColumn('column1', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER)->addColumn('column2', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER)->addIndex($this->_oneColumnIdxName, ['column1'])->addIndex($this->_twoColumnIdxName, ['column1', 'column2']);
$this->_connection->createTable($table);
}
示例2: _cleanRelationProducts
/**
* Clean unused relation products
*
* @param int $storeId
* @return \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction
*/
protected function _cleanRelationProducts($storeId)
{
if (!$this->_productIndexerHelper->isAddChildData()) {
return $this;
}
$metadata = $this->metadataPool->getMetadata(ProductInterface::class);
foreach ($this->_getProductTypeInstances() as $typeInstance) {
/** @var $typeInstance \Magento\Catalog\Model\Product\Type\AbstractType */
if (!$typeInstance->isComposite(null)) {
continue;
}
$relation = $typeInstance->getRelationInfo();
if ($relation && $relation->getTable() && $relation->getParentFieldName() && $relation->getChildFieldName()) {
$select = $this->_connection->select()->distinct(true)->from(['t' => $this->_productIndexerHelper->getTable($relation->getTable())], [])->join(['entity_table' => $this->_connection->getTableName('catalog_product_entity')], 'entity_table.' . $metadata->getLinkField() . 't.' . $relation->getParentFieldName(), [$relation->getParentFieldName() => 'entity_table.entity_id']);
$joinLeftCond = ["e.entity_id = entity_table.entity_id", "e.child_id = t.{$relation->getChildFieldName()}"];
if ($relation->getWhere() !== null) {
$select->where($relation->getWhere());
$joinLeftCond[] = $relation->getWhere();
}
$entitySelect = new \Zend_Db_Expr($select->__toString());
/** @var $select \Magento\Framework\DB\Select */
$select = $this->_connection->select()->from(['e' => $this->_productIndexerHelper->getFlatTableName($storeId)], null)->joinLeft(['t' => $this->_productIndexerHelper->getTable($relation->getTable())], implode(' AND ', $joinLeftCond), [])->where('e.is_child = ?', 1)->where('e.entity_id IN(?)', $entitySelect)->where("t.{$relation->getChildFieldName()} IS NULL");
$sql = $select->deleteFromSelect('e');
$this->_connection->query($sql);
}
}
return $this;
}
示例3: createDelta
/**
* Create delta for specified table
*
* @param string $documentName
* @param string $deltaLogName
* @param string $idKey
* @return void
*/
public function createDelta($documentName, $deltaLogName, $idKey)
{
if (!$this->resourceAdapter->isTableExists($deltaLogName)) {
$triggerTable = $this->resourceAdapter->newTable($deltaLogName)->addColumn($idKey, \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['nullable' => false, 'primary' => true])->addColumn('operation', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT)->addColumn('processed', \Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN, null, ['nullable' => false, 'default' => 0]);
$this->resourceAdapter->createTable($triggerTable);
} else {
$this->deleteAllRecords($deltaLogName);
}
foreach (Trigger::getListOfEvents() as $event) {
$triggerName = $this->resourceAdapter->getTableName('trg_' . $documentName . '_after_' . strtolower($event));
$statement = $this->buildStatement($event, $idKey, $deltaLogName);
$trigger = $this->triggerFactory->create()->setTime(Trigger::TIME_AFTER)->setEvent($event)->setTable($documentName);
$triggerKey = $documentName . $event . Trigger::TIME_AFTER;
$triggerExists = $this->isTriggerExist($triggerKey);
if ($triggerExists) {
$triggerName = $this->triggers[$triggerKey]['trigger_name'];
$oldTriggerStatement = $this->triggers[$triggerKey]['action_statement'];
if (strpos($oldTriggerStatement, $statement) !== false) {
unset($trigger);
continue;
}
$trigger->addStatement($oldTriggerStatement);
$this->resourceAdapter->dropTrigger($triggerName);
}
$trigger->addStatement($statement)->setName($triggerName);
$this->resourceAdapter->createTrigger($trigger);
if (!$triggerExists) {
$this->triggers[$triggerKey] = 1;
}
unset($trigger);
}
}
示例4: getTemporaryTreeIndexTableName
/**
* Get temporary table name for concurrent indexing in persistent connection
* Temp table name is NOT shared between action instances and each action has it's own temp tree index
*
* @return string
*/
protected function getTemporaryTreeIndexTableName()
{
if (empty($this->tempTreeIndexTableName)) {
$this->tempTreeIndexTableName = $this->connection->getTableName('temp_catalog_category_tree_index') . '_' . substr(md5(time() . rand(0, 999999999)), 0, 8);
}
return $this->tempTreeIndexTableName;
}
示例5: getTable
/**
* Get table name (validated by db adapter) by table placeholder
*
* @param string|array $tableName
* @return string
*/
public function getTable($tableName)
{
$tablePrefix = (string) $this->tablePrefix;
if ($tablePrefix && strpos($tableName, $tablePrefix) !== 0) {
$tableName = $tablePrefix . $tableName;
}
$cacheKey = $this->getTableCacheName($tableName);
if (!isset($this->tables[$cacheKey])) {
$this->tables[$cacheKey] = $this->connection->getTableName($tableName);
}
return $this->tables[$cacheKey];
}
示例6: getAttributeTypeValues
/**
* Return attribute values for given entities and store of specific attribute type
*
* @param string $type
* @param array $entityIds
* @param integer $storeId
* @return array
*/
protected function getAttributeTypeValues($type, $entityIds, $storeId)
{
$linkField = $this->getCategoryMetadata()->getLinkField();
$select = $this->connection->select()->from(['def' => $this->connection->getTableName($this->getTableName('catalog_category_entity_' . $type))], [$linkField, 'attribute_id'])->joinLeft(['e' => $this->connection->getTableName($this->getTableName('catalog_category_entity'))], "def.{$linkField} = e.{$linkField}")->joinLeft(['store' => $this->connection->getTableName($this->getTableName('catalog_category_entity_' . $type))], "store.{$linkField} = def.{$linkField} AND store.attribute_id = def.attribute_id " . 'AND store.store_id = ' . $storeId, ['value' => $this->connection->getCheckSql('store.value_id > 0', $this->connection->quoteIdentifier('store.value'), $this->connection->quoteIdentifier('def.value'))])->where("e.entity_id IN (?)", $entityIds)->where('def.store_id IN (?)', [\Magento\Store\Model\Store::DEFAULT_STORE_ID, $storeId]);
return $this->connection->fetchAll($select);
}