943f2d724b3b20730669e10760df8af712247c9f
[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:6666108a662d719144f390bf4746268d)
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 * Field to show when displaying a record.
28 *
29 * @var string
30 */
31 public static $_labelField = 'name';
32
33 /**
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
35 *
36 * @var bool
37 */
38 public static $_log = FALSE;
39
40 /**
41 * County ID
42 *
43 * @var int
44 */
45 public $id;
46
47 /**
48 * Name of County
49 *
50 * @var string
51 */
52 public $name;
53
54 /**
55 * 2-4 Character Abbreviation of County
56 *
57 * @var string
58 */
59 public $abbreviation;
60
61 /**
62 * ID of State/Province that County belongs
63 *
64 * @var int
65 */
66 public $state_province_id;
67
68 /**
69 * Is this County active?
70 *
71 * @var bool
72 */
73 public $is_active;
74
75 /**
76 * Class constructor.
77 */
78 public function __construct() {
79 $this->__table = 'civicrm_county';
80 parent::__construct();
81 }
82
83 /**
84 * Returns localized title of this entity.
85 *
86 * @param bool $plural
87 * Whether to return the plural version of the title.
88 */
89 public static function getEntityTitle($plural = FALSE) {
90 return $plural ? ts('Counties') : ts('County');
91 }
92
93 /**
94 * Returns foreign keys and entity references.
95 *
96 * @return array
97 * [CRM_Core_Reference_Interface]
98 */
99 public static function getReferenceColumns() {
100 if (!isset(Civi::$statics[__CLASS__]['links'])) {
101 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
102 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'state_province_id', 'civicrm_state_province', 'id');
103 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
104 }
105 return Civi::$statics[__CLASS__]['links'];
106 }
107
108 /**
109 * Returns all the column names of this table
110 *
111 * @return array
112 */
113 public static function &fields() {
114 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
115 Civi::$statics[__CLASS__]['fields'] = [
116 'id' => [
117 'name' => 'id',
118 'type' => CRM_Utils_Type::T_INT,
119 'title' => ts('County ID'),
120 'description' => ts('County ID'),
121 'required' => TRUE,
122 'where' => 'civicrm_county.id',
123 'table_name' => 'civicrm_county',
124 'entity' => 'County',
125 'bao' => 'CRM_Core_DAO_County',
126 'localizable' => 0,
127 'html' => [
128 'type' => 'Number',
129 ],
130 'readonly' => TRUE,
131 'add' => '1.1',
132 ],
133 'name' => [
134 'name' => 'name',
135 'type' => CRM_Utils_Type::T_STRING,
136 'title' => ts('County'),
137 'description' => ts('Name of County'),
138 'maxlength' => 64,
139 'size' => CRM_Utils_Type::BIG,
140 'import' => TRUE,
141 'where' => 'civicrm_county.name',
142 'headerPattern' => '/county/i',
143 'dataPattern' => '/[A-Z]{2}/',
144 'export' => TRUE,
145 'table_name' => 'civicrm_county',
146 'entity' => 'County',
147 'bao' => 'CRM_Core_DAO_County',
148 'localizable' => 0,
149 'add' => '1.1',
150 ],
151 'abbreviation' => [
152 'name' => 'abbreviation',
153 'type' => CRM_Utils_Type::T_STRING,
154 'title' => ts('County Abbreviation'),
155 'description' => ts('2-4 Character Abbreviation of County'),
156 'maxlength' => 4,
157 'size' => CRM_Utils_Type::FOUR,
158 'where' => 'civicrm_county.abbreviation',
159 'table_name' => 'civicrm_county',
160 'entity' => 'County',
161 'bao' => 'CRM_Core_DAO_County',
162 'localizable' => 0,
163 'add' => '1.1',
164 ],
165 'state_province_id' => [
166 'name' => 'state_province_id',
167 'type' => CRM_Utils_Type::T_INT,
168 'title' => ts('State ID'),
169 'description' => ts('ID of State/Province that County belongs'),
170 'required' => TRUE,
171 'where' => 'civicrm_county.state_province_id',
172 'table_name' => 'civicrm_county',
173 'entity' => 'County',
174 'bao' => 'CRM_Core_DAO_County',
175 'localizable' => 0,
176 'FKClassName' => 'CRM_Core_DAO_StateProvince',
177 'html' => [
178 'label' => ts("State"),
179 ],
180 'pseudoconstant' => [
181 'table' => 'civicrm_state_province',
182 'keyColumn' => 'id',
183 'labelColumn' => 'name',
184 ],
185 'add' => '1.1',
186 ],
187 'is_active' => [
188 'name' => 'is_active',
189 'type' => CRM_Utils_Type::T_BOOLEAN,
190 'title' => ts('County Is Active'),
191 'description' => ts('Is this County active?'),
192 'where' => 'civicrm_county.is_active',
193 'default' => '1',
194 'table_name' => 'civicrm_county',
195 'entity' => 'County',
196 'bao' => 'CRM_Core_DAO_County',
197 'localizable' => 0,
198 'add' => '5.35',
199 ],
200 ];
201 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
202 }
203 return Civi::$statics[__CLASS__]['fields'];
204 }
205
206 /**
207 * Return a mapping from field-name to the corresponding key (as used in fields()).
208 *
209 * @return array
210 * Array(string $name => string $uniqueName).
211 */
212 public static function &fieldKeys() {
213 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
214 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
215 }
216 return Civi::$statics[__CLASS__]['fieldKeys'];
217 }
218
219 /**
220 * Returns the names of this table
221 *
222 * @return string
223 */
224 public static function getTableName() {
225 return self::$_tableName;
226 }
227
228 /**
229 * Returns if this table needs to be logged
230 *
231 * @return bool
232 */
233 public function getLog() {
234 return self::$_log;
235 }
236
237 /**
238 * Returns the list of fields that can be imported
239 *
240 * @param bool $prefix
241 *
242 * @return array
243 */
244 public static function &import($prefix = FALSE) {
245 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'county', $prefix, []);
246 return $r;
247 }
248
249 /**
250 * Returns the list of fields that can be exported
251 *
252 * @param bool $prefix
253 *
254 * @return array
255 */
256 public static function &export($prefix = FALSE) {
257 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'county', $prefix, []);
258 return $r;
259 }
260
261 /**
262 * Returns the list of indices
263 *
264 * @param bool $localize
265 *
266 * @return array
267 */
268 public static function indices($localize = TRUE) {
269 $indices = [
270 'UI_name_state_id' => [
271 'name' => 'UI_name_state_id',
272 'field' => [
273 0 => 'name',
274 1 => 'state_province_id',
275 ],
276 'localizable' => FALSE,
277 'unique' => TRUE,
278 'sig' => 'civicrm_county::1::name::state_province_id',
279 ],
280 ];
281 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
282 }
283
284 }