Regenerate DAO files
[civicrm-core.git] / CRM / Core / DAO / Country.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Country.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:cdd80b394924586274cf4b91183d3637)
10 */
11
12 /**
13 * Database access object for the Country entity.
14 */
15 class CRM_Core_DAO_Country 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_country';
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 * Country Id
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Country Name
42 *
43 * @var string
44 */
45 public $name;
46
47 /**
48 * ISO Code
49 *
50 * @var string
51 */
52 public $iso_code;
53
54 /**
55 * National prefix to be used when dialing TO this country.
56 *
57 * @var string
58 */
59 public $country_code;
60
61 /**
62 * Foreign key to civicrm_address_format.id.
63 *
64 * @var int
65 */
66 public $address_format_id;
67
68 /**
69 * International direct dialing prefix from within the country TO another country
70 *
71 * @var string
72 */
73 public $idd_prefix;
74
75 /**
76 * Access prefix to call within a country to a different area
77 *
78 * @var string
79 */
80 public $ndd_prefix;
81
82 /**
83 * Foreign key to civicrm_worldregion.id.
84 *
85 * @var int
86 */
87 public $region_id;
88
89 /**
90 * Should state/province be displayed as abbreviation for contacts from this country?
91 *
92 * @var bool
93 */
94 public $is_province_abbreviated;
95
96 /**
97 * Class constructor.
98 */
99 public function __construct() {
100 $this->__table = 'civicrm_country';
101 parent::__construct();
102 }
103
104 /**
105 * Returns localized title of this entity.
106 */
107 public static function getEntityTitle() {
108 return ts('Countries');
109 }
110
111 /**
112 * Returns foreign keys and entity references.
113 *
114 * @return array
115 * [CRM_Core_Reference_Interface]
116 */
117 public static function getReferenceColumns() {
118 if (!isset(Civi::$statics[__CLASS__]['links'])) {
119 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
120 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'address_format_id', 'civicrm_address_format', 'id');
121 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'region_id', 'civicrm_worldregion', 'id');
122 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
123 }
124 return Civi::$statics[__CLASS__]['links'];
125 }
126
127 /**
128 * Returns all the column names of this table
129 *
130 * @return array
131 */
132 public static function &fields() {
133 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
134 Civi::$statics[__CLASS__]['fields'] = [
135 'id' => [
136 'name' => 'id',
137 'type' => CRM_Utils_Type::T_INT,
138 'title' => ts('Country ID'),
139 'description' => ts('Country Id'),
140 'required' => TRUE,
141 'where' => 'civicrm_country.id',
142 'table_name' => 'civicrm_country',
143 'entity' => 'Country',
144 'bao' => 'CRM_Core_BAO_Country',
145 'localizable' => 0,
146 'add' => '1.1',
147 ],
148 'name' => [
149 'name' => 'name',
150 'type' => CRM_Utils_Type::T_STRING,
151 'title' => ts('Country'),
152 'description' => ts('Country Name'),
153 'maxlength' => 64,
154 'size' => CRM_Utils_Type::BIG,
155 'import' => TRUE,
156 'where' => 'civicrm_country.name',
157 'headerPattern' => '/country/i',
158 'dataPattern' => '/^[A-Z][a-z]+\.?(\s+[A-Z][a-z]+){0,3}$/',
159 'export' => TRUE,
160 'table_name' => 'civicrm_country',
161 'entity' => 'Country',
162 'bao' => 'CRM_Core_BAO_Country',
163 'localizable' => 0,
164 'add' => '1.1',
165 ],
166 'iso_code' => [
167 'name' => 'iso_code',
168 'type' => CRM_Utils_Type::T_STRING,
169 'title' => ts('Country ISO Code'),
170 'description' => ts('ISO Code'),
171 'maxlength' => 2,
172 'size' => CRM_Utils_Type::TWO,
173 'where' => 'civicrm_country.iso_code',
174 'table_name' => 'civicrm_country',
175 'entity' => 'Country',
176 'bao' => 'CRM_Core_BAO_Country',
177 'localizable' => 0,
178 'add' => '1.1',
179 ],
180 'country_code' => [
181 'name' => 'country_code',
182 'type' => CRM_Utils_Type::T_STRING,
183 'title' => ts('Country Phone Prefix'),
184 'description' => ts('National prefix to be used when dialing TO this country.'),
185 'maxlength' => 4,
186 'size' => CRM_Utils_Type::FOUR,
187 'where' => 'civicrm_country.country_code',
188 'table_name' => 'civicrm_country',
189 'entity' => 'Country',
190 'bao' => 'CRM_Core_BAO_Country',
191 'localizable' => 0,
192 'add' => '1.1',
193 ],
194 'address_format_id' => [
195 'name' => 'address_format_id',
196 'type' => CRM_Utils_Type::T_INT,
197 'title' => ts('Address Format'),
198 'description' => ts('Foreign key to civicrm_address_format.id.'),
199 'where' => 'civicrm_country.address_format_id',
200 'table_name' => 'civicrm_country',
201 'entity' => 'Country',
202 'bao' => 'CRM_Core_BAO_Country',
203 'localizable' => 0,
204 'FKClassName' => 'CRM_Core_DAO_AddressFormat',
205 'add' => '3.2',
206 ],
207 'idd_prefix' => [
208 'name' => 'idd_prefix',
209 'type' => CRM_Utils_Type::T_STRING,
210 'title' => ts('Outgoing Phone Prefix'),
211 'description' => ts('International direct dialing prefix from within the country TO another country'),
212 'maxlength' => 4,
213 'size' => CRM_Utils_Type::FOUR,
214 'where' => 'civicrm_country.idd_prefix',
215 'table_name' => 'civicrm_country',
216 'entity' => 'Country',
217 'bao' => 'CRM_Core_BAO_Country',
218 'localizable' => 0,
219 'add' => '1.1',
220 ],
221 'ndd_prefix' => [
222 'name' => 'ndd_prefix',
223 'type' => CRM_Utils_Type::T_STRING,
224 'title' => ts('Area Code'),
225 'description' => ts('Access prefix to call within a country to a different area'),
226 'maxlength' => 4,
227 'size' => CRM_Utils_Type::FOUR,
228 'where' => 'civicrm_country.ndd_prefix',
229 'table_name' => 'civicrm_country',
230 'entity' => 'Country',
231 'bao' => 'CRM_Core_BAO_Country',
232 'localizable' => 0,
233 'add' => '1.1',
234 ],
235 'region_id' => [
236 'name' => 'region_id',
237 'type' => CRM_Utils_Type::T_INT,
238 'title' => ts('World Region ID'),
239 'description' => ts('Foreign key to civicrm_worldregion.id.'),
240 'required' => TRUE,
241 'where' => 'civicrm_country.region_id',
242 'table_name' => 'civicrm_country',
243 'entity' => 'Country',
244 'bao' => 'CRM_Core_BAO_Country',
245 'localizable' => 0,
246 'localize_context' => 'country',
247 'FKClassName' => 'CRM_Core_DAO_Worldregion',
248 'pseudoconstant' => [
249 'table' => 'civicrm_worldregion',
250 'keyColumn' => 'id',
251 'labelColumn' => 'name',
252 ],
253 'add' => '1.8',
254 ],
255 'is_province_abbreviated' => [
256 'name' => 'is_province_abbreviated',
257 'type' => CRM_Utils_Type::T_BOOLEAN,
258 'title' => ts('Abbreviate Province?'),
259 'description' => ts('Should state/province be displayed as abbreviation for contacts from this country?'),
260 'where' => 'civicrm_country.is_province_abbreviated',
261 'default' => '0',
262 'table_name' => 'civicrm_country',
263 'entity' => 'Country',
264 'bao' => 'CRM_Core_BAO_Country',
265 'localizable' => 0,
266 'add' => '3.1',
267 ],
268 ];
269 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
270 }
271 return Civi::$statics[__CLASS__]['fields'];
272 }
273
274 /**
275 * Return a mapping from field-name to the corresponding key (as used in fields()).
276 *
277 * @return array
278 * Array(string $name => string $uniqueName).
279 */
280 public static function &fieldKeys() {
281 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
282 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
283 }
284 return Civi::$statics[__CLASS__]['fieldKeys'];
285 }
286
287 /**
288 * Returns the names of this table
289 *
290 * @return string
291 */
292 public static function getTableName() {
293 return self::$_tableName;
294 }
295
296 /**
297 * Returns if this table needs to be logged
298 *
299 * @return bool
300 */
301 public function getLog() {
302 return self::$_log;
303 }
304
305 /**
306 * Returns the list of fields that can be imported
307 *
308 * @param bool $prefix
309 *
310 * @return array
311 */
312 public static function &import($prefix = FALSE) {
313 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'country', $prefix, []);
314 return $r;
315 }
316
317 /**
318 * Returns the list of fields that can be exported
319 *
320 * @param bool $prefix
321 *
322 * @return array
323 */
324 public static function &export($prefix = FALSE) {
325 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'country', $prefix, []);
326 return $r;
327 }
328
329 /**
330 * Returns the list of indices
331 *
332 * @param bool $localize
333 *
334 * @return array
335 */
336 public static function indices($localize = TRUE) {
337 $indices = [
338 'UI_name_iso_code' => [
339 'name' => 'UI_name_iso_code',
340 'field' => [
341 0 => 'name',
342 1 => 'iso_code',
343 ],
344 'localizable' => FALSE,
345 'unique' => TRUE,
346 'sig' => 'civicrm_country::1::name::iso_code',
347 ],
348 ];
349 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
350 }
351
352 }