本文整理汇总了PHP中Magento\Framework\DB\Adapter\AdapterInterface::insertMultiple方法的典型用法代码示例。如果您正苦于以下问题:PHP AdapterInterface::insertMultiple方法的具体用法?PHP AdapterInterface::insertMultiple怎么用?PHP AdapterInterface::insertMultiple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\DB\Adapter\AdapterInterface
的用法示例。
在下文中一共展示了AdapterInterface::insertMultiple方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testInsertMultiple
/**
* @dataProvider insertDataProvider
*/
public function testInsertMultiple($data)
{
$this->_connection->insertMultiple($this->_tableName, $data);
$select = $this->_connection->select()->from($this->_tableName);
$result = $this->_connection->fetchRow($select);
$this->assertEquals($data, $result);
}
示例2: insertMultiple
/**
* Insert multiple
*
* @param array $data
* @return void
* @throws \Magento\Framework\Exception\AlreadyExistsException
* @throws \Exception
*/
protected function insertMultiple($data)
{
try {
$this->connection->insertMultiple($this->resource->getTableName(self::TABLE_NAME), $data);
} catch (\Exception $e) {
if ($e->getCode() === self::ERROR_CODE_DUPLICATE_ENTRY && preg_match('#SQLSTATE\\[23000\\]: [^:]+: 1062[^\\d]#', $e->getMessage())) {
throw new \Magento\Framework\Exception\AlreadyExistsException(__('URL key for specified store already exists.'));
}
throw $e;
}
}
示例3: insertMultiple
/**
* Insert multiple
*
* @param array $data
* @return void
* @throws DuplicateEntryException
* @throws \Exception
*/
protected function insertMultiple($data)
{
try {
$this->connection->insertMultiple($this->resource->getTableName(self::TABLE_NAME), $data);
} catch (\Exception $e) {
if ($e->getCode() === self::ERROR_CODE_DUPLICATE_ENTRY && preg_match('#SQLSTATE\\[23000\\]: [^:]+: 1062[^\\d]#', $e->getMessage())) {
throw new DuplicateEntryException();
}
throw $e;
}
}
示例4: insertRecords
/**
* @inheritdoc
*/
public function insertRecords($documentName, $records, $updateOnDuplicate = false)
{
$this->resourceAdapter->rawQuery("SET @OLD_INSERT_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'");
if ($updateOnDuplicate) {
$result = $this->resourceAdapter->insertOnDuplicate($documentName, $records);
} else {
$result = $this->resourceAdapter->insertMultiple($documentName, $records);
}
$this->resourceAdapter->rawQuery("SET SQL_MODE=IFNULL(@OLD_INSERT_SQL_MODE,'')");
return $result;
}
示例5: updateRuleProductData
/**
* @param Rule $rule
* @return $this
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function updateRuleProductData(Rule $rule)
{
$ruleId = $rule->getId();
if ($rule->getProductsFilter()) {
$this->connection->delete($this->getTable('catalogrule_product'), ['rule_id=?' => $ruleId, 'product_id IN (?)' => $rule->getProductsFilter()]);
} else {
$this->connection->delete($this->getTable('catalogrule_product'), $this->connection->quoteInto('rule_id=?', $ruleId));
}
if (!$rule->getIsActive()) {
return $this;
}
$websiteIds = $rule->getWebsiteIds();
if (!is_array($websiteIds)) {
$websiteIds = explode(',', $websiteIds);
}
if (empty($websiteIds)) {
return $this;
}
\Magento\Framework\Profiler::start('__MATCH_PRODUCTS__');
$productIds = $rule->getMatchingProductIds();
\Magento\Framework\Profiler::stop('__MATCH_PRODUCTS__');
$customerGroupIds = $rule->getCustomerGroupIds();
$fromTime = strtotime($rule->getFromDate());
$toTime = strtotime($rule->getToDate());
$toTime = $toTime ? $toTime + self::SECONDS_IN_DAY - 1 : 0;
$sortOrder = (int) $rule->getSortOrder();
$actionOperator = $rule->getSimpleAction();
$actionAmount = $rule->getDiscountAmount();
$subActionOperator = $rule->getSubIsEnable() ? $rule->getSubSimpleAction() : '';
$subActionAmount = $rule->getSubDiscountAmount();
$actionStop = $rule->getStopRulesProcessing();
$rows = [];
foreach ($productIds as $productId => $validationByWebsite) {
foreach ($websiteIds as $websiteId) {
if (empty($validationByWebsite[$websiteId])) {
continue;
}
foreach ($customerGroupIds as $customerGroupId) {
$rows[] = ['rule_id' => $ruleId, 'from_time' => $fromTime, 'to_time' => $toTime, 'website_id' => $websiteId, 'customer_group_id' => $customerGroupId, 'product_id' => $productId, 'action_operator' => $actionOperator, 'action_amount' => $actionAmount, 'action_stop' => $actionStop, 'sort_order' => $sortOrder, 'sub_simple_action' => $subActionOperator, 'sub_discount_amount' => $subActionAmount];
if (count($rows) == $this->batchCount) {
$this->connection->insertMultiple($this->getTable('catalogrule_product'), $rows);
$rows = [];
}
}
}
}
if (!empty($rows)) {
$this->connection->insertMultiple($this->getTable('catalogrule_product'), $rows);
}
return $this;
}
示例6: doAddMultiple
/**
* {@inheritdoc}
*/
protected function doAddMultiple($data)
{
$this->connection->insertMultiple(self::TABLE_NAME, $data);
}
示例7: _saveSpecificTypeValues
/**
* Save custom option type values
*
* @param array $typeValues Option type values
* @return $this
*/
protected function _saveSpecificTypeValues(array $typeValues)
{
$this->_deleteSpecificTypeValues(array_keys($typeValues));
$typeValueRows = array();
foreach ($typeValues as $optionId => $optionInfo) {
foreach ($optionInfo as $row) {
$row['option_id'] = $optionId;
$typeValueRows[] = $row;
}
}
if ($typeValueRows) {
$this->_connection->insertMultiple($this->_tables['catalog_product_option_type_value'], $typeValueRows);
}
return $this;
}