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