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