Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
userdevicelogintable.php
1<?php
10
11use Bitrix\Main;
14
32{
33 use Data\Internal\DeleteByFilterTrait;
34
35 public static function getTableName()
36 {
37 return 'b_user_device_login';
38 }
39
40 public static function getMap()
41 {
42 return [
43 (new Fields\IntegerField('ID'))
44 ->configurePrimary(true)
45 ->configureAutocomplete(true),
46
47 (new Fields\IntegerField('DEVICE_ID'))
48 ->addValidator(new Fields\Validators\ForeignValidator(UserDeviceTable::getEntity()->getField('ID'))),
49
50 (new Fields\DatetimeField('LOGIN_DATE')),
51
52 (new Fields\StringField('IP')),
53
54 (new Fields\IntegerField('CITY_GEOID'))
55 ->configureNullable(),
56
57 (new Fields\IntegerField('REGION_GEOID'))
58 ->configureNullable(),
59
60 (new Fields\StringField('COUNTRY_ISO_CODE'))
61 ->configureNullable(),
62
63 (new Fields\IntegerField('APP_PASSWORD_ID'))
64 ->configureNullable(),
65
66 (new Fields\IntegerField('STORED_AUTH_ID'))
67 ->configureNullable(),
68
69 (new Fields\IntegerField('HIT_AUTH_ID'))
70 ->configureNullable(),
71 ];
72 }
73
74 public static function deleteByDeviceFilter($where)
75 {
76 if($where == '')
77 {
78 throw new Main\ArgumentException("Deleting by empty filter is not allowed, use truncate (b_user_device_login).", "where");
79 }
80
81 $entity = static::getEntity();
82 $conn = $entity->getConnection();
83
84 $conn->query("
85 DELETE DL FROM b_user_device_login DL
86 WHERE DL.DEVICE_ID IN(
87 SELECT ID FROM b_user_device
88 {$where}
89 )"
90 );
91
92 $entity->cleanCache();
93 }
94}