Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
addresslinktable.php
1<?php
2
4
8
26{
32 public static function getTableName()
33 {
34 return 'b_location_addr_link';
35 }
36
42 public static function getMap()
43 {
44 return [
45
46 (new Fields\IntegerField('ADDRESS_ID'))
47 ->configurePrimary(true),
48
49 (new Fields\StringField('ENTITY_ID'))
50 ->configurePrimary(true)
51 ->addValidator(new Main\ORM\Fields\Validators\LengthValidator(1, 100)),
52
53 // todo: int
54 (new Fields\StringField('ENTITY_TYPE'))
55 ->configurePrimary(true)
56 ->addValidator(new Main\ORM\Fields\Validators\LengthValidator(1, 50)),
57
58 // Ref
59
60 (new Fields\Relations\Reference('ADDRESS', AddressTable::class,
61 Join::on('this.ADDRESS_ID', 'ref.ID')))
62 ->configureJoinType('inner')
63 ];
64 }
65
70 public static function deleteByAddressId(int $addressId): void
71 {
72 Main\Application::getConnection()->queryExecute("
73 DELETE
74 FROM ".self::getTableName()."
75 WHERE
76 ADDRESS_ID=".(int)$addressId
77 );
78 }
79
84 public static function deleteByEntityType(string $entityType): void
85 {
86 $connection = Main\Application::getConnection();
87 $sqlHelper = $connection->getSqlHelper();
88
89 Main\Application::getConnection()->queryExecute("
90 DELETE
91 FROM ".self::getTableName()."
92 WHERE
93 ENTITY_TYPE = '".$sqlHelper->forSql($entityType)."'"
94 );
95 }
96}