Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
access.php
1<?php
2
4
8
27class AccessTable extends Entity\DataManager
28{
35 public static function getTableName()
36 {
37 return 'b_sender_role_access';
38 }
39
46 public static function getMap()
47 {
48 return array(
49 'ID' => new Entity\IntegerField('ID', array(
50 'primary' => true,
51 'autocomplete' => true,
52 )),
53 'ROLE_ID' => new Entity\IntegerField('ROLE_ID', array(
54 'required' => true,
55 )),
56 'ACCESS_CODE' => new Entity\StringField('ACCESS_CODE', array(
57 'required' => true,
58 )),
59 'ROLE' => new Entity\ReferenceField(
60 'ROLE', 'Bitrix\Sender\Access\Role\Role',
61 array('=this.ROLE_ID' => 'ref.ID'),
62 array('join_type' => 'INNER')
63 )
64 );
65 }
66
72 public static function truncate()
73 {
74 $sql = "TRUNCATE TABLE " . self::getTableName();
75 Application::getConnection()->queryExecute($sql);
76
77 $result = new Entity\DeleteResult();
78 return $result;
79 }
80
88 public static function deleteByRoleId($roleId)
89 {
90 $roleId = (int) $roleId;
91 if($roleId <= 0)
92 {
93 throw new ArgumentException('Role id should be greater than zero', 'roleId');
94 }
95
96 $sql = "DELETE FROM " . self::getTableName() . " WHERE ROLE_ID = " . $roleId;
97 Application::getConnection()->queryExecute($sql);
98
99 $result = new Entity\DeleteResult();
100 return $result;
101 }
102}
static getConnection($name="")