5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/Country.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:e5b8ae0961e387f04f4fa49cb92144cf)
13 * Database access object for the Country entity.
15 class CRM_Core_DAO_Country
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_country';
27 * Field to show when displaying a record.
31 public static $_labelField = 'name';
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = FALSE;
62 * National prefix to be used when dialing TO this country.
69 * Foreign key to civicrm_address_format.id.
73 public $address_format_id;
76 * International direct dialing prefix from within the country TO another country
83 * Access prefix to call within a country to a different area
90 * Foreign key to civicrm_worldregion.id.
97 * Should state/province be displayed as abbreviation for contacts from this country?
101 public $is_province_abbreviated;
104 * Is this Country active?
113 public function __construct() {
114 $this->__table
= 'civicrm_country';
115 parent
::__construct();
119 * Returns localized title of this entity.
121 * @param bool $plural
122 * Whether to return the plural version of the title.
124 public static function getEntityTitle($plural = FALSE) {
125 return $plural ?
ts('Countries') : ts('Country');
129 * Returns foreign keys and entity references.
132 * [CRM_Core_Reference_Interface]
134 public static function getReferenceColumns() {
135 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
136 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
137 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'address_format_id', 'civicrm_address_format', 'id');
138 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'region_id', 'civicrm_worldregion', 'id');
139 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
141 return Civi
::$statics[__CLASS__
]['links'];
145 * Returns all the column names of this table
149 public static function &fields() {
150 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
151 Civi
::$statics[__CLASS__
]['fields'] = [
154 'type' => CRM_Utils_Type
::T_INT
,
155 'title' => ts('Country ID'),
156 'description' => ts('Country ID'),
158 'where' => 'civicrm_country.id',
159 'table_name' => 'civicrm_country',
160 'entity' => 'Country',
161 'bao' => 'CRM_Core_BAO_Country',
170 'type' => CRM_Utils_Type
::T_STRING
,
171 'title' => ts('Country'),
172 'description' => ts('Country Name'),
174 'size' => CRM_Utils_Type
::BIG
,
176 'where' => 'civicrm_country.name',
177 'headerPattern' => '/country/i',
178 'dataPattern' => '/^[A-Z][a-z]+\.?(\s+[A-Z][a-z]+){0,3}$/',
180 'table_name' => 'civicrm_country',
181 'entity' => 'Country',
182 'bao' => 'CRM_Core_BAO_Country',
187 'name' => 'iso_code',
188 'type' => CRM_Utils_Type
::T_STRING
,
189 'title' => ts('Country ISO Code'),
190 'description' => ts('ISO Code'),
192 'size' => CRM_Utils_Type
::TWO
,
193 'where' => 'civicrm_country.iso_code',
194 'table_name' => 'civicrm_country',
195 'entity' => 'Country',
196 'bao' => 'CRM_Core_BAO_Country',
201 'name' => 'country_code',
202 'type' => CRM_Utils_Type
::T_STRING
,
203 'title' => ts('Country Phone Prefix'),
204 'description' => ts('National prefix to be used when dialing TO this country.'),
206 'size' => CRM_Utils_Type
::FOUR
,
207 'where' => 'civicrm_country.country_code',
208 'table_name' => 'civicrm_country',
209 'entity' => 'Country',
210 'bao' => 'CRM_Core_BAO_Country',
214 'address_format_id' => [
215 'name' => 'address_format_id',
216 'type' => CRM_Utils_Type
::T_INT
,
217 'title' => ts('Address Format ID'),
218 'description' => ts('Foreign key to civicrm_address_format.id.'),
219 'where' => 'civicrm_country.address_format_id',
220 'table_name' => 'civicrm_country',
221 'entity' => 'Country',
222 'bao' => 'CRM_Core_BAO_Country',
224 'FKClassName' => 'CRM_Core_DAO_AddressFormat',
226 'label' => ts("Address Format"),
231 'name' => 'idd_prefix',
232 'type' => CRM_Utils_Type
::T_STRING
,
233 'title' => ts('Outgoing Phone Prefix'),
234 'description' => ts('International direct dialing prefix from within the country TO another country'),
236 'size' => CRM_Utils_Type
::FOUR
,
237 'where' => 'civicrm_country.idd_prefix',
238 'table_name' => 'civicrm_country',
239 'entity' => 'Country',
240 'bao' => 'CRM_Core_BAO_Country',
245 'name' => 'ndd_prefix',
246 'type' => CRM_Utils_Type
::T_STRING
,
247 'title' => ts('Area Code'),
248 'description' => ts('Access prefix to call within a country to a different area'),
250 'size' => CRM_Utils_Type
::FOUR
,
251 'where' => 'civicrm_country.ndd_prefix',
252 'table_name' => 'civicrm_country',
253 'entity' => 'Country',
254 'bao' => 'CRM_Core_BAO_Country',
259 'name' => 'region_id',
260 'type' => CRM_Utils_Type
::T_INT
,
261 'title' => ts('World Region ID'),
262 'description' => ts('Foreign key to civicrm_worldregion.id.'),
264 'where' => 'civicrm_country.region_id',
265 'table_name' => 'civicrm_country',
266 'entity' => 'Country',
267 'bao' => 'CRM_Core_BAO_Country',
269 'localize_context' => 'country',
270 'FKClassName' => 'CRM_Core_DAO_Worldregion',
272 'label' => ts("World Region"),
274 'pseudoconstant' => [
275 'table' => 'civicrm_worldregion',
277 'labelColumn' => 'name',
281 'is_province_abbreviated' => [
282 'name' => 'is_province_abbreviated',
283 'type' => CRM_Utils_Type
::T_BOOLEAN
,
284 'title' => ts('Abbreviate Province?'),
285 'description' => ts('Should state/province be displayed as abbreviation for contacts from this country?'),
286 'where' => 'civicrm_country.is_province_abbreviated',
288 'table_name' => 'civicrm_country',
289 'entity' => 'Country',
290 'bao' => 'CRM_Core_BAO_Country',
295 'name' => 'is_active',
296 'type' => CRM_Utils_Type
::T_BOOLEAN
,
297 'title' => ts('Country Is Active'),
298 'description' => ts('Is this Country active?'),
299 'where' => 'civicrm_country.is_active',
301 'table_name' => 'civicrm_country',
302 'entity' => 'Country',
303 'bao' => 'CRM_Core_BAO_Country',
308 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
310 return Civi
::$statics[__CLASS__
]['fields'];
314 * Return a mapping from field-name to the corresponding key (as used in fields()).
317 * Array(string $name => string $uniqueName).
319 public static function &fieldKeys() {
320 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
321 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
323 return Civi
::$statics[__CLASS__
]['fieldKeys'];
327 * Returns the names of this table
331 public static function getTableName() {
332 return self
::$_tableName;
336 * Returns if this table needs to be logged
340 public function getLog() {
345 * Returns the list of fields that can be imported
347 * @param bool $prefix
351 public static function &import($prefix = FALSE) {
352 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'country', $prefix, []);
357 * Returns the list of fields that can be exported
359 * @param bool $prefix
363 public static function &export($prefix = FALSE) {
364 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'country', $prefix, []);
369 * Returns the list of indices
371 * @param bool $localize
375 public static function indices($localize = TRUE) {
377 'UI_name_iso_code' => [
378 'name' => 'UI_name_iso_code',
383 'localizable' => FALSE,
385 'sig' => 'civicrm_country::1::name::iso_code',
388 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;