1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
InsertIgnoreTrait.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\OpenEvents\Internals;
4
5use Bitrix\Main\Application;
6
7trait InsertIgnoreTrait
8{
9 // TODO: create trait in main
10 public static function insertIgnore(array $insertFields): void
11 {
12 $sqlHelper = Application::getConnection()->getSqlHelper();
13
14 $tableName = $sqlHelper->quote(self::getTableName());
15 [$columns, $values] = $sqlHelper->prepareInsert(self::getTableName(), $insertFields);
16
17 $sql = $sqlHelper->getInsertIgnore($tableName, "($columns)", "VALUES ($values)");
18
19 Application::getConnection()->queryExecute($sql);
20 }
21
22 public static function insertIgnoreMulti(array $insertRows): void
23 {
24 $sqlHelper = Application::getConnection()->getSqlHelper();
25
26 $tableName = $sqlHelper->quote(self::getTableName());
27 [$columns, $inserts] = self::prepareInsertMulti($insertRows);
28
29 if (!$columns || !$inserts)
30 {
31 throw new \Exception(sprintf('wrong insert fields for %s', $tableName));
32 }
33
34 $sql = $sqlHelper->getInsertIgnore($tableName, "($columns)", "VALUES $inserts");
35
36 Application::getConnection()->queryExecute($sql);
37 }
38
39 private static function prepareInsertMulti(array $fields): array
40 {
41 $sqlHelper = Application::getConnection()->getSqlHelper();
42 $inserts = [];
43 $columns = null;
44
45 foreach ($fields as $insertField)
46 {
47 $insert = $sqlHelper->prepareInsert(self::getTableName(), $insertField);
48 if (!$columns)
49 {
50 $columns = $insert[0];
51 }
52 $inserts[] = "({$insert[1]})";
53 }
54
55 return [$columns, implode(',', $inserts)];
56 }
57}
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$fields
Определения yandex_run.php:501