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


PHP AdapterInterface::createTable方法代码示例

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


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

示例1: create

 /**
  * Create changelog table
  *
  * @return void
  * @throws \Exception
  */
 public function create()
 {
     $changelogTableName = $this->resource->getTableName($this->getName());
     if (!$this->connection->isTableExists($changelogTableName)) {
         $table = $this->connection->newTable($changelogTableName)->addColumn('version_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'Version ID')->addColumn($this->getColumnName(), \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['unsigned' => true, 'nullable' => false, 'default' => '0'], 'Entity ID');
         $this->connection->createTable($table);
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:Changelog.php

示例2: setUp

 protected function setUp()
 {
     $installer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Module\\Setup', array('resourceName' => 'core_setup', 'moduleName' => 'Magento_Core'));
     $this->_connection = $installer->getConnection();
     $this->_tableName = $installer->getTable('table_two_column_idx');
     $this->_oneColumnIdxName = $installer->getIdxName($this->_tableName, array('column1'));
     $this->_twoColumnIdxName = $installer->getIdxName($this->_tableName, array('column1', 'column2'));
     $table = $this->_connection->newTable($this->_tableName)->addColumn('id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, array('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, array('column1'))->addIndex($this->_twoColumnIdxName, array('column1', 'column2'));
     $this->_connection->createTable($table);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:10,代码来源:InterfaceTest.php

示例3: 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);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:InterfaceTest.php

示例4: 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);
     }
 }
开发者ID:victor-v-rad,项目名称:data-migration-tool,代码行数:40,代码来源:Mysql.php

示例5: create

 /**
  * Create changelog table
  *
  * @return void
  * @throws \Exception
  */
 public function create()
 {
     $changelogTableName = $this->resource->getTableName($this->getName());
     if ($this->write->isTableExists($changelogTableName)) {
         throw new \Exception("Table {$changelogTableName} already exist");
     }
     $table = $this->write->newTable($changelogTableName)->addColumn('version_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), 'Version ID')->addColumn($this->getColumnName(), \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, array('unsigned' => true, 'nullable' => false, 'default' => '0'), 'Entity ID');
     $this->write->createTable($table);
 }
开发者ID:,项目名称:,代码行数:15,代码来源:

示例6: _createTemporaryFlatTable

 /**
  * Prepare flat table for store
  *
  * @param int|string $storeId
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _createTemporaryFlatTable($storeId)
 {
     $columns = $this->_productIndexerHelper->getFlatColumns();
     $indexesNeed = $this->_productIndexerHelper->getFlatIndexes();
     $maxIndex = $this->_config->getValue(self::XML_NODE_MAX_INDEX_COUNT);
     if ($maxIndex && count($indexesNeed) > $maxIndex) {
         throw new \Magento\Framework\Exception\LocalizedException(__('The Flat Catalog module has a limit of %2$d filterable and/or sortable attributes.' . 'Currently there are %1$d of them.' . 'Please reduce the number of filterable/sortable attributes in order to use this module', count($indexesNeed), $maxIndex));
     }
     $indexKeys = [];
     $indexProps = array_values($indexesNeed);
     $upperPrimaryKey = strtoupper(\Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_PRIMARY);
     foreach ($indexProps as $i => $indexProp) {
         $indexName = $this->_connection->getIndexName($this->_getTemporaryTableName($this->_productIndexerHelper->getFlatTableName($storeId)), $indexProp['fields'], $indexProp['type']);
         $indexProp['type'] = strtoupper($indexProp['type']);
         if ($indexProp['type'] == $upperPrimaryKey) {
             $indexKey = $upperPrimaryKey;
         } else {
             $indexKey = $indexName;
         }
         $indexProps[$i] = ['KEY_NAME' => $indexName, 'COLUMNS_LIST' => $indexProp['fields'], 'INDEX_TYPE' => strtolower($indexProp['type'])];
         $indexKeys[$i] = $indexKey;
     }
     $indexesNeed = array_combine($indexKeys, $indexProps);
     /** @var $table \Magento\Framework\DB\Ddl\Table */
     $table = $this->_connection->newTable($this->_getTemporaryTableName($this->_productIndexerHelper->getFlatTableName($storeId)));
     foreach ($columns as $fieldName => $fieldProp) {
         $columnLength = isset($fieldProp['length']) ? $fieldProp['length'] : null;
         $columnDefinition = ['nullable' => isset($fieldProp['nullable']) ? (bool) $fieldProp['nullable'] : false, 'unsigned' => isset($fieldProp['unsigned']) ? (bool) $fieldProp['unsigned'] : false, 'default' => isset($fieldProp['default']) ? $fieldProp['default'] : false, 'primary' => false];
         $columnComment = isset($fieldProp['comment']) ? $fieldProp['comment'] : $fieldName;
         $table->addColumn($fieldName, $fieldProp['type'], $columnLength, $columnDefinition, $columnComment);
     }
     foreach ($indexesNeed as $indexProp) {
         $table->addIndex($indexProp['KEY_NAME'], $indexProp['COLUMNS_LIST'], ['type' => $indexProp['INDEX_TYPE']]);
     }
     $table->setComment("Catalog Product Flat (Store {$storeId})");
     $this->_connection->dropTable($this->_getTemporaryTableName($this->_productIndexerHelper->getFlatTableName($storeId)));
     $this->_connection->createTable($table);
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:47,代码来源:FlatTableBuilder.php

示例7: setupFlagTable

 /**
  * Create table 'flag'
  *
  * @param SchemaSetupInterface $setup
  * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
  * @return void
  */
 private function setupFlagTable(
     SchemaSetupInterface $setup,
     \Magento\Framework\DB\Adapter\AdapterInterface $connection
 ) {
     if (!$connection->isTableExists($setup->getTable('flag'))) {
         $table = $connection->newTable(
             $setup->getTable('flag')
         )->addColumn(
             'flag_id',
             \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
             null,
             ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
             'Flag Id'
         )->addColumn(
             'flag_code',
             \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
             255,
             ['nullable' => false],
             'Flag Code'
         )->addColumn(
             'state',
             \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
             null,
             ['unsigned' => true, 'nullable' => false, 'default' => '0'],
             'Flag State'
         )->addColumn(
             'flag_data',
             \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
             '64k',
             [],
             'Flag Data'
         )->addColumn(
             'last_update',
             \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
             null,
             ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE],
             'Date of Last Flag Update'
         )->addIndex(
             $setup->getIdxName('flag', ['last_update']),
             ['last_update']
         )->setComment(
             'Flag'
         );
         $connection->createTable($table);
     }
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:53,代码来源:Installer.php


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