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