376f3738f82cd17ec3a4967719496e3f937d4f89
[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:a7e07335fea6b1eea5894c119eaa1c4e)
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 unsigned
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 unsigned
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 unsigned
84 */
85 public $region_id;
86
87 /**
88 * Should state/province be displayed as abbreviation for contacts from this country?
89 *
90 * @var boolean
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 'table_name' => 'civicrm_country',
133 'entity' => 'Country',
134 'bao' => 'CRM_Core_BAO_Country',
135 'localizable' => 0,
136 ],
137 'name' => [
138 'name' => 'name',
139 'type' => CRM_Utils_Type::T_STRING,
140 'title' => ts('Country'),
141 'description' => ts('Country Name'),
142 'maxlength' => 64,
143 'size' => CRM_Utils_Type::BIG,
144 'import' => TRUE,
145 'where' => 'civicrm_country.name',
146 'headerPattern' => '/country/i',
147 'dataPattern' => '/^[A-Z][a-z]+\.?(\s+[A-Z][a-z]+){0,3}$/',
148 'export' => TRUE,
149 'table_name' => 'civicrm_country',
150 'entity' => 'Country',
151 'bao' => 'CRM_Core_BAO_Country',
152 'localizable' => 0,
153 ],
154 'iso_code' => [
155 'name' => 'iso_code',
156 'type' => CRM_Utils_Type::T_STRING,
157 'title' => ts('Country ISO Code'),
158 'description' => ts('ISO Code'),
159 'maxlength' => 2,
160 'size' => CRM_Utils_Type::TWO,
161 'table_name' => 'civicrm_country',
162 'entity' => 'Country',
163 'bao' => 'CRM_Core_BAO_Country',
164 'localizable' => 0,
165 ],
166 'country_code' => [
167 'name' => 'country_code',
168 'type' => CRM_Utils_Type::T_STRING,
169 'title' => ts('Country Phone Prefix'),
170 'description' => ts('National prefix to be used when dialing TO this country.'),
171 'maxlength' => 4,
172 'size' => CRM_Utils_Type::FOUR,
173 'table_name' => 'civicrm_country',
174 'entity' => 'Country',
175 'bao' => 'CRM_Core_BAO_Country',
176 'localizable' => 0,
177 ],
178 'address_format_id' => [
179 'name' => 'address_format_id',
180 'type' => CRM_Utils_Type::T_INT,
181 'title' => ts('Address Format'),
182 'description' => ts('Foreign key to civicrm_address_format.id.'),
183 'table_name' => 'civicrm_country',
184 'entity' => 'Country',
185 'bao' => 'CRM_Core_BAO_Country',
186 'localizable' => 0,
187 'FKClassName' => 'CRM_Core_DAO_AddressFormat',
188 ],
189 'idd_prefix' => [
190 'name' => 'idd_prefix',
191 'type' => CRM_Utils_Type::T_STRING,
192 'title' => ts('Outgoing Phone Prefix'),
193 'description' => ts('International direct dialing prefix from within the country TO another country'),
194 'maxlength' => 4,
195 'size' => CRM_Utils_Type::FOUR,
196 'table_name' => 'civicrm_country',
197 'entity' => 'Country',
198 'bao' => 'CRM_Core_BAO_Country',
199 'localizable' => 0,
200 ],
201 'ndd_prefix' => [
202 'name' => 'ndd_prefix',
203 'type' => CRM_Utils_Type::T_STRING,
204 'title' => ts('Area Code'),
205 'description' => ts('Access prefix to call within a country to a different area'),
206 'maxlength' => 4,
207 'size' => CRM_Utils_Type::FOUR,
208 'table_name' => 'civicrm_country',
209 'entity' => 'Country',
210 'bao' => 'CRM_Core_BAO_Country',
211 'localizable' => 0,
212 ],
213 'region_id' => [
214 'name' => 'region_id',
215 'type' => CRM_Utils_Type::T_INT,
216 'title' => ts('World Region ID'),
217 'description' => ts('Foreign key to civicrm_worldregion.id.'),
218 'required' => TRUE,
219 'table_name' => 'civicrm_country',
220 'entity' => 'Country',
221 'bao' => 'CRM_Core_BAO_Country',
222 'localizable' => 0,
223 'localize_context' => 'country',
224 'FKClassName' => 'CRM_Core_DAO_Worldregion',
225 'pseudoconstant' => [
226 'table' => 'civicrm_worldregion',
227 'keyColumn' => 'id',
228 'labelColumn' => 'name',
229 ]
230 ],
231 'is_province_abbreviated' => [
232 'name' => 'is_province_abbreviated',
233 'type' => CRM_Utils_Type::T_BOOLEAN,
234 'title' => ts('Abbreviate Province?'),
235 'description' => ts('Should state/province be displayed as abbreviation for contacts from this country?'),
236 'default' => '0',
237 'table_name' => 'civicrm_country',
238 'entity' => 'Country',
239 'bao' => 'CRM_Core_BAO_Country',
240 'localizable' => 0,
241 ],
242 ];
243 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
244 }
245 return Civi::$statics[__CLASS__]['fields'];
246 }
247
248 /**
249 * Return a mapping from field-name to the corresponding key (as used in fields()).
250 *
251 * @return array
252 * Array(string $name => string $uniqueName).
253 */
254 public static function &fieldKeys() {
255 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
256 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
257 }
258 return Civi::$statics[__CLASS__]['fieldKeys'];
259 }
260
261 /**
262 * Returns the names of this table
263 *
264 * @return string
265 */
266 public static function getTableName() {
267 return self::$_tableName;
268 }
269
270 /**
271 * Returns if this table needs to be logged
272 *
273 * @return bool
274 */
275 public function getLog() {
276 return self::$_log;
277 }
278
279 /**
280 * Returns the list of fields that can be imported
281 *
282 * @param bool $prefix
283 *
284 * @return array
285 */
286 public static function &import($prefix = FALSE) {
287 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'country', $prefix, []);
288 return $r;
289 }
290
291 /**
292 * Returns the list of fields that can be exported
293 *
294 * @param bool $prefix
295 *
296 * @return array
297 */
298 public static function &export($prefix = FALSE) {
299 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'country', $prefix, []);
300 return $r;
301 }
302
303 /**
304 * Returns the list of indices
305 *
306 * @param bool $localize
307 *
308 * @return array
309 */
310 public static function indices($localize = TRUE) {
311 $indices = [
312 'UI_name_iso_code' => [
313 'name' => 'UI_name_iso_code',
314 'field' => [
315 0 => 'name',
316 1 => 'iso_code',
317 ],
318 'localizable' => FALSE,
319 'unique' => TRUE,
320 'sig' => 'civicrm_country::1::name::iso_code',
321 ],
322 ];
323 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
324 }
325
326 }