Merge pull request #18276 from civicrm/5.29
[civicrm-core.git] / CRM / Core / DAO / County.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/County.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:96f94dbbafff9a4e1f0ff276799fcbbd)
10 */
11
12 /**
13 * Database access object for the County entity.
14 */
15 class CRM_Core_DAO_County extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_county';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = FALSE;
32
33 /**
34 * County ID
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Name of County
42 *
43 * @var string
44 */
45 public $name;
46
47 /**
48 * 2-4 Character Abbreviation of County
49 *
50 * @var string
51 */
52 public $abbreviation;
53
54 /**
55 * ID of State/Province that County belongs
56 *
57 * @var int
58 */
59 public $state_province_id;
60
61 /**
62 * Class constructor.
63 */
64 public function __construct() {
65 $this->__table = 'civicrm_county';
66 parent::__construct();
67 }
68
69 /**
70 * Returns localized title of this entity.
71 */
72 public static function getEntityTitle() {
73 return ts('Counties');
74 }
75
76 /**
77 * Returns foreign keys and entity references.
78 *
79 * @return array
80 * [CRM_Core_Reference_Interface]
81 */
82 public static function getReferenceColumns() {
83 if (!isset(Civi::$statics[__CLASS__]['links'])) {
84 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
85 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'state_province_id', 'civicrm_state_province', 'id');
86 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
87 }
88 return Civi::$statics[__CLASS__]['links'];
89 }
90
91 /**
92 * Returns all the column names of this table
93 *
94 * @return array
95 */
96 public static function &fields() {
97 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
98 Civi::$statics[__CLASS__]['fields'] = [
99 'id' => [
100 'name' => 'id',
101 'type' => CRM_Utils_Type::T_INT,
102 'title' => ts('County ID'),
103 'description' => ts('County ID'),
104 'required' => TRUE,
105 'where' => 'civicrm_county.id',
106 'table_name' => 'civicrm_county',
107 'entity' => 'County',
108 'bao' => 'CRM_Core_DAO_County',
109 'localizable' => 0,
110 'add' => '1.1',
111 ],
112 'name' => [
113 'name' => 'name',
114 'type' => CRM_Utils_Type::T_STRING,
115 'title' => ts('County'),
116 'description' => ts('Name of County'),
117 'maxlength' => 64,
118 'size' => CRM_Utils_Type::BIG,
119 'import' => TRUE,
120 'where' => 'civicrm_county.name',
121 'headerPattern' => '/county/i',
122 'dataPattern' => '/[A-Z]{2}/',
123 'export' => TRUE,
124 'table_name' => 'civicrm_county',
125 'entity' => 'County',
126 'bao' => 'CRM_Core_DAO_County',
127 'localizable' => 0,
128 'add' => '1.1',
129 ],
130 'abbreviation' => [
131 'name' => 'abbreviation',
132 'type' => CRM_Utils_Type::T_STRING,
133 'title' => ts('County Abbreviation'),
134 'description' => ts('2-4 Character Abbreviation of County'),
135 'maxlength' => 4,
136 'size' => CRM_Utils_Type::FOUR,
137 'where' => 'civicrm_county.abbreviation',
138 'table_name' => 'civicrm_county',
139 'entity' => 'County',
140 'bao' => 'CRM_Core_DAO_County',
141 'localizable' => 0,
142 'add' => '1.1',
143 ],
144 'state_province_id' => [
145 'name' => 'state_province_id',
146 'type' => CRM_Utils_Type::T_INT,
147 'title' => ts('State'),
148 'description' => ts('ID of State/Province that County belongs'),
149 'required' => TRUE,
150 'where' => 'civicrm_county.state_province_id',
151 'table_name' => 'civicrm_county',
152 'entity' => 'County',
153 'bao' => 'CRM_Core_DAO_County',
154 'localizable' => 0,
155 'FKClassName' => 'CRM_Core_DAO_StateProvince',
156 'pseudoconstant' => [
157 'table' => 'civicrm_state_province',
158 'keyColumn' => 'id',
159 'labelColumn' => 'name',
160 ],
161 'add' => '1.1',
162 ],
163 ];
164 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
165 }
166 return Civi::$statics[__CLASS__]['fields'];
167 }
168
169 /**
170 * Return a mapping from field-name to the corresponding key (as used in fields()).
171 *
172 * @return array
173 * Array(string $name => string $uniqueName).
174 */
175 public static function &fieldKeys() {
176 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
177 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
178 }
179 return Civi::$statics[__CLASS__]['fieldKeys'];
180 }
181
182 /**
183 * Returns the names of this table
184 *
185 * @return string
186 */
187 public static function getTableName() {
188 return self::$_tableName;
189 }
190
191 /**
192 * Returns if this table needs to be logged
193 *
194 * @return bool
195 */
196 public function getLog() {
197 return self::$_log;
198 }
199
200 /**
201 * Returns the list of fields that can be imported
202 *
203 * @param bool $prefix
204 *
205 * @return array
206 */
207 public static function &import($prefix = FALSE) {
208 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'county', $prefix, []);
209 return $r;
210 }
211
212 /**
213 * Returns the list of fields that can be exported
214 *
215 * @param bool $prefix
216 *
217 * @return array
218 */
219 public static function &export($prefix = FALSE) {
220 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'county', $prefix, []);
221 return $r;
222 }
223
224 /**
225 * Returns the list of indices
226 *
227 * @param bool $localize
228 *
229 * @return array
230 */
231 public static function indices($localize = TRUE) {
232 $indices = [
233 'UI_name_state_id' => [
234 'name' => 'UI_name_state_id',
235 'field' => [
236 0 => 'name',
237 1 => 'state_province_id',
238 ],
239 'localizable' => FALSE,
240 'unique' => TRUE,
241 'sig' => 'civicrm_county::1::name::state_province_id',
242 ],
243 ];
244 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
245 }
246
247 }