本文整理匯總了PHP中Magento\Framework\DB\Adapter\AdapterInterface::insertFromSelect方法的典型用法代碼示例。如果您正苦於以下問題:PHP AdapterInterface::insertFromSelect方法的具體用法?PHP AdapterInterface::insertFromSelect怎麽用?PHP AdapterInterface::insertFromSelect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\DB\Adapter\AdapterInterface
的用法示例。
在下文中一共展示了AdapterInterface::insertFromSelect方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: reindexRootCategory
/**
* Reindex all products to root category
*
* @param \Magento\Store\Model\Store $store
* @return void
*/
protected function reindexRootCategory(\Magento\Store\Model\Store $store)
{
if ($this->isIndexRootCategoryNeeded()) {
$selects = $this->prepareSelectsByRange($this->getAllProducts($store), 'entity_id', self::RANGE_PRODUCT_STEP);
foreach ($selects as $select) {
$this->connection->query($this->connection->insertFromSelect($select, $this->getMainTmpTable(), ['category_id', 'product_id', 'position', 'is_parent', 'store_id', 'visibility'], \Magento\Framework\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE));
}
}
}
示例2: _insertFromTable
/**
* Copy data from source table to destination
*
* @param string $sourceTable
* @param string $destTable
* @param null|string $where
* @return void
*/
protected function _insertFromTable($sourceTable, $destTable, $where = null)
{
$sourceColumns = array_keys($this->_connection->describeTable($sourceTable));
$targetColumns = array_keys($this->_connection->describeTable($destTable));
$select = $this->_connection->select()->from($sourceTable, $sourceColumns);
if ($where) {
$select->where($where);
}
$query = $this->_connection->insertFromSelect($select, $destTable, $targetColumns, \Magento\Framework\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE);
$this->_connection->query($query);
}
示例3: rollbackDocument
/**
* @inheritdoc
*/
public function rollbackDocument($documentName)
{
$backupTableName = self::BACKUP_DOCUMENT_PREFIX . $documentName;
if ($this->resourceAdapter->isTableExists($backupTableName)) {
$this->resourceAdapter->truncateTable($documentName);
$select = $this->resourceAdapter->select()->from($backupTableName);
$query = $this->resourceAdapter->insertFromSelect($select, $documentName);
$this->resourceAdapter->query($query);
$this->resourceAdapter->dropTable($backupTableName);
}
}