Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
businessvalue_persondomain.php
1<?php
2
4
6
23class BusinessValuePersonDomainTable extends Main\Entity\DataManager
24{
25 public static function getFilePath()
26 {
27 return __FILE__;
28 }
29
30 public static function getTableName()
31 {
32 return 'b_sale_bizval_persondomain';
33 }
34
35 public static function getMap()
36 {
37 return array(
38 new Main\Entity\IntegerField('PERSON_TYPE_ID', array('primary' => true)),
39 new Main\Entity\StringField ('DOMAIN', array('primary' => true, 'size' => 1)),
40
41 new Main\Entity\ReferenceField('PERSON_TYPE_REFERENCE', 'Bitrix\Sale\Internals\PersonTypeTable',
42 array('=this.PERSON_TYPE_ID' => 'ref.ID'),
43 array('join_type' => 'INNER')
44 ),
45 );
46 }
47
48 public static function deleteByPersonTypeId(int $personTypeId) : Main\ORM\Data\DeleteResult
49 {
50 $result = new Main\ORM\Data\DeleteResult();
51
52 $dbRes = static::getList([
53 'select' => ['PERSON_TYPE_ID', 'DOMAIN'],
54 'filter' => [
55 '=PERSON_TYPE_ID' => $personTypeId
56 ]
57 ]);
58
59 while ($item = $dbRes->fetch())
60 {
61 $r = static::delete([
62 'PERSON_TYPE_ID' => $item['PERSON_TYPE_ID'],
63 'DOMAIN' => $item['DOMAIN'],
64 ]);
65
66 if (!$r->isSuccess())
67 {
68 $result->addErrors($r->getErrors());
69 }
70 }
71
72 return $result;
73 }
74}