37 return 'b_sale_d_ix_section';
49 'data_type' =>
'integer',
51 'autocomplete' =>
true,
53 'DISCOUNT_ID' => array(
54 'data_type' =>
'integer',
58 'data_type' =>
'\Bitrix\Sale\Internals\DiscountTable',
60 '=this.DISCOUNT_ID' =>
'ref.ID'
62 'join_type' =>
'INNER',
64 'DISCOUNT_GROUP' => array(
65 'data_type' =>
'\Bitrix\Sale\Internals\DiscountGroupTable',
67 '=this.DISCOUNT_ID' =>
'ref.DISCOUNT_ID'
69 'join_type' =>
'INNER',
71 'SECTION_ID' => array(
72 'data_type' =>
'integer',
86 $discountId = (int)$discountId;
93 $helper = $connection->getSqlHelper();
94 $connection->queryExecute(
95 'delete from ' . $helper->quote(self::getTableName()) .
96 ' where ' . $helper->quote(
'DISCOUNT_ID') .
' = ' . $discountId
103 foreach($indexData as $sectionId)
106 'DISCOUNT_ID' => $discountId,
107 'SECTION_ID' => $sectionId,
111 static::insertBatch($items);
119 private static function insertBatch(array $items)
121 $tableName = static::getTableName();
123 $sqlHelper = $connection->getSqlHelper();
125 $query = $prefix =
'';
128 foreach($items as $item)
130 list($prefix, $values) = $sqlHelper->prepareInsert($tableName, $item);
132 $query .= ($query ?
', ' :
' ') .
'(' . $values .
')';
135 $connection->queryExecute(
"INSERT INTO {$tableName} ({$prefix}) VALUES {$query}");
141 if($query && $prefix)
143 $connection->queryExecute(
"INSERT INTO {$tableName} ({$prefix}) VALUES {$query}");
146 elseif($connection instanceof MssqlConnection)
148 $valueData = array();
149 foreach($items as $item)
151 list($prefix, $values) = $sqlHelper->prepareInsert($tableName, $item);
152 $valueData[] =
"SELECT {$values}";
156 $valuesSql = implode(
' UNION ALL ', $valueData);
157 if($valuesSql && $prefix)
159 $connection->queryExecute(
"INSERT INTO {$tableName} ({$prefix}) $valuesSql");
162 elseif($connection instanceof OracleConnection)
164 $valueData = array();
165 foreach($items as $item)
167 list($prefix, $values) = $sqlHelper->prepareInsert($tableName, $item);
168 $valueData[] =
"SELECT {$values} FROM dual";
172 $valuesSql = implode(
' UNION ALL ', $valueData);
173 if($valuesSql && $prefix)
175 $connection->queryExecute(
"INSERT INTO {$tableName} ({$prefix}) $valuesSql");
static getConnection($name="")