Merge pull request #14326 from civicrm/5.14
[civicrm-core.git] / CRM / Contact / DAO / GroupContactCache.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Contact/GroupContactCache.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:217f20fad2d47f50e3a9c43b62df2c17)
10 */
11
12 /**
13 * Database access object for the GroupContactCache entity.
14 */
15 class CRM_Contact_DAO_GroupContactCache extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_group_contact_cache';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 public static $_log = FALSE;
30
31 /**
32 * primary key
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * FK to civicrm_group
40 *
41 * @var int
42 */
43 public $group_id;
44
45 /**
46 * FK to civicrm_contact
47 *
48 * @var int
49 */
50 public $contact_id;
51
52 /**
53 * Class constructor.
54 */
55 public function __construct() {
56 $this->__table = 'civicrm_group_contact_cache';
57 parent::__construct();
58 }
59
60 /**
61 * Returns foreign keys and entity references.
62 *
63 * @return array
64 * [CRM_Core_Reference_Interface]
65 */
66 public static function getReferenceColumns() {
67 if (!isset(Civi::$statics[__CLASS__]['links'])) {
68 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
69 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id');
70 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
71 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
72 }
73 return Civi::$statics[__CLASS__]['links'];
74 }
75
76 /**
77 * Returns all the column names of this table
78 *
79 * @return array
80 */
81 public static function &fields() {
82 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
83 Civi::$statics[__CLASS__]['fields'] = [
84 'id' => [
85 'name' => 'id',
86 'type' => CRM_Utils_Type::T_INT,
87 'title' => ts('Group Contact Cache ID'),
88 'description' => ts('primary key'),
89 'required' => TRUE,
90 'where' => 'civicrm_group_contact_cache.id',
91 'table_name' => 'civicrm_group_contact_cache',
92 'entity' => 'GroupContactCache',
93 'bao' => 'CRM_Contact_BAO_GroupContactCache',
94 'localizable' => 0,
95 ],
96 'group_id' => [
97 'name' => 'group_id',
98 'type' => CRM_Utils_Type::T_INT,
99 'title' => ts('Group'),
100 'description' => ts('FK to civicrm_group'),
101 'required' => TRUE,
102 'where' => 'civicrm_group_contact_cache.group_id',
103 'table_name' => 'civicrm_group_contact_cache',
104 'entity' => 'GroupContactCache',
105 'bao' => 'CRM_Contact_BAO_GroupContactCache',
106 'localizable' => 0,
107 'FKClassName' => 'CRM_Contact_DAO_Group',
108 'html' => [
109 'type' => 'Select',
110 ],
111 'pseudoconstant' => [
112 'table' => 'civicrm_group',
113 'keyColumn' => 'id',
114 'labelColumn' => 'title',
115 ],
116 ],
117 'contact_id' => [
118 'name' => 'contact_id',
119 'type' => CRM_Utils_Type::T_INT,
120 'title' => ts('Contact ID'),
121 'description' => ts('FK to civicrm_contact'),
122 'required' => TRUE,
123 'where' => 'civicrm_group_contact_cache.contact_id',
124 'table_name' => 'civicrm_group_contact_cache',
125 'entity' => 'GroupContactCache',
126 'bao' => 'CRM_Contact_BAO_GroupContactCache',
127 'localizable' => 0,
128 'FKClassName' => 'CRM_Contact_DAO_Contact',
129 ],
130 ];
131 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
132 }
133 return Civi::$statics[__CLASS__]['fields'];
134 }
135
136 /**
137 * Return a mapping from field-name to the corresponding key (as used in fields()).
138 *
139 * @return array
140 * Array(string $name => string $uniqueName).
141 */
142 public static function &fieldKeys() {
143 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
144 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
145 }
146 return Civi::$statics[__CLASS__]['fieldKeys'];
147 }
148
149 /**
150 * Returns the names of this table
151 *
152 * @return string
153 */
154 public static function getTableName() {
155 return self::$_tableName;
156 }
157
158 /**
159 * Returns if this table needs to be logged
160 *
161 * @return bool
162 */
163 public function getLog() {
164 return self::$_log;
165 }
166
167 /**
168 * Returns the list of fields that can be imported
169 *
170 * @param bool $prefix
171 *
172 * @return array
173 */
174 public static function &import($prefix = FALSE) {
175 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group_contact_cache', $prefix, []);
176 return $r;
177 }
178
179 /**
180 * Returns the list of fields that can be exported
181 *
182 * @param bool $prefix
183 *
184 * @return array
185 */
186 public static function &export($prefix = FALSE) {
187 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group_contact_cache', $prefix, []);
188 return $r;
189 }
190
191 /**
192 * Returns the list of indices
193 *
194 * @param bool $localize
195 *
196 * @return array
197 */
198 public static function indices($localize = TRUE) {
199 $indices = [
200 'UI_contact_group' => [
201 'name' => 'UI_contact_group',
202 'field' => [
203 0 => 'contact_id',
204 1 => 'group_id',
205 ],
206 'localizable' => FALSE,
207 'unique' => TRUE,
208 'sig' => 'civicrm_group_contact_cache::1::contact_id::group_id',
209 ],
210 ];
211 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
212 }
213
214 }