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:27aa4dca6a02c9e3827feff015f759fe)
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;
43 * @var int|string|null
44 * (SQL type: int unsigned)
45 * Note that values will be retrieved from the database as a string.
53 * (SQL type: varchar(64))
54 * Note that values will be retrieved from the database as a string.
63 * Note that values will be retrieved from the database as a string.
68 * National prefix to be used when dialing TO this country.
71 * (SQL type: varchar(4))
72 * Note that values will be retrieved from the database as a string.
77 * Foreign key to civicrm_address_format.id.
79 * @var int|string|null
80 * (SQL type: int unsigned)
81 * Note that values will be retrieved from the database as a string.
83 public $address_format_id;
86 * International direct dialing prefix from within the country TO another country
89 * (SQL type: varchar(4))
90 * Note that values will be retrieved from the database as a string.
95 * Access prefix to call within a country to a different area
98 * (SQL type: varchar(4))
99 * Note that values will be retrieved from the database as a string.
104 * Foreign key to civicrm_worldregion.id.
107 * (SQL type: int unsigned)
108 * Note that values will be retrieved from the database as a string.
113 * Should state/province be displayed as abbreviation for contacts from this country?
116 * (SQL type: tinyint)
117 * Note that values will be retrieved from the database as a string.
119 public $is_province_abbreviated;
122 * Is this Country active?
125 * (SQL type: tinyint)
126 * Note that values will be retrieved from the database as a string.
133 public function __construct() {
134 $this->__table
= 'civicrm_country';
135 parent
::__construct();
139 * Returns localized title of this entity.
141 * @param bool $plural
142 * Whether to return the plural version of the title.
144 public static function getEntityTitle($plural = FALSE) {
145 return $plural ?
ts('Countries') : ts('Country');
149 * Returns foreign keys and entity references.
152 * [CRM_Core_Reference_Interface]
154 public static function getReferenceColumns() {
155 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
156 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
157 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'address_format_id', 'civicrm_address_format', 'id');
158 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'region_id', 'civicrm_worldregion', 'id');
159 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
161 return Civi
::$statics[__CLASS__
]['links'];
165 * Returns all the column names of this table
169 public static function &fields() {
170 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
171 Civi
::$statics[__CLASS__
]['fields'] = [
174 'type' => CRM_Utils_Type
::T_INT
,
175 'title' => ts('Country ID'),
176 'description' => ts('Country ID'),
178 'where' => 'civicrm_country.id',
179 'table_name' => 'civicrm_country',
180 'entity' => 'Country',
181 'bao' => 'CRM_Core_BAO_Country',
191 'type' => CRM_Utils_Type
::T_STRING
,
192 'title' => ts('Country'),
193 'description' => ts('Country Name'),
195 'size' => CRM_Utils_Type
::BIG
,
197 'where' => 'civicrm_country.name',
198 'headerPattern' => '/country/i',
199 'dataPattern' => '/^[A-Z][a-z]+\.?(\s+[A-Z][a-z]+){0,3}$/',
201 'table_name' => 'civicrm_country',
202 'entity' => 'Country',
203 'bao' => 'CRM_Core_BAO_Country',
208 'name' => 'iso_code',
209 'type' => CRM_Utils_Type
::T_STRING
,
210 'title' => ts('Country ISO Code'),
211 'description' => ts('ISO Code'),
213 'size' => CRM_Utils_Type
::TWO
,
214 'where' => 'civicrm_country.iso_code',
215 'table_name' => 'civicrm_country',
216 'entity' => 'Country',
217 'bao' => 'CRM_Core_BAO_Country',
222 'name' => 'country_code',
223 'type' => CRM_Utils_Type
::T_STRING
,
224 'title' => ts('Country Phone Prefix'),
225 'description' => ts('National prefix to be used when dialing TO this country.'),
227 'size' => CRM_Utils_Type
::FOUR
,
228 'where' => 'civicrm_country.country_code',
229 'table_name' => 'civicrm_country',
230 'entity' => 'Country',
231 'bao' => 'CRM_Core_BAO_Country',
235 'address_format_id' => [
236 'name' => 'address_format_id',
237 'type' => CRM_Utils_Type
::T_INT
,
238 'title' => ts('Address Format ID'),
239 'description' => ts('Foreign key to civicrm_address_format.id.'),
240 'where' => 'civicrm_country.address_format_id',
241 'table_name' => 'civicrm_country',
242 'entity' => 'Country',
243 'bao' => 'CRM_Core_BAO_Country',
245 'FKClassName' => 'CRM_Core_DAO_AddressFormat',
247 'label' => ts("Address Format"),
252 'name' => 'idd_prefix',
253 'type' => CRM_Utils_Type
::T_STRING
,
254 'title' => ts('Outgoing Phone Prefix'),
255 'description' => ts('International direct dialing prefix from within the country TO another country'),
257 'size' => CRM_Utils_Type
::FOUR
,
258 'where' => 'civicrm_country.idd_prefix',
259 'table_name' => 'civicrm_country',
260 'entity' => 'Country',
261 'bao' => 'CRM_Core_BAO_Country',
266 'name' => 'ndd_prefix',
267 'type' => CRM_Utils_Type
::T_STRING
,
268 'title' => ts('Area Code'),
269 'description' => ts('Access prefix to call within a country to a different area'),
271 'size' => CRM_Utils_Type
::FOUR
,
272 'where' => 'civicrm_country.ndd_prefix',
273 'table_name' => 'civicrm_country',
274 'entity' => 'Country',
275 'bao' => 'CRM_Core_BAO_Country',
280 'name' => 'region_id',
281 'type' => CRM_Utils_Type
::T_INT
,
282 'title' => ts('World Region ID'),
283 'description' => ts('Foreign key to civicrm_worldregion.id.'),
285 'where' => 'civicrm_country.region_id',
286 'table_name' => 'civicrm_country',
287 'entity' => 'Country',
288 'bao' => 'CRM_Core_BAO_Country',
290 'localize_context' => 'country',
291 'FKClassName' => 'CRM_Core_DAO_Worldregion',
293 'label' => ts("World Region"),
295 'pseudoconstant' => [
296 'table' => 'civicrm_worldregion',
298 'labelColumn' => 'name',
302 'is_province_abbreviated' => [
303 'name' => 'is_province_abbreviated',
304 'type' => CRM_Utils_Type
::T_BOOLEAN
,
305 'title' => ts('Abbreviate Province?'),
306 'description' => ts('Should state/province be displayed as abbreviation for contacts from this country?'),
308 'where' => 'civicrm_country.is_province_abbreviated',
310 'table_name' => 'civicrm_country',
311 'entity' => 'Country',
312 'bao' => 'CRM_Core_BAO_Country',
317 'name' => 'is_active',
318 'type' => CRM_Utils_Type
::T_BOOLEAN
,
319 'title' => ts('Country Is Active'),
320 'description' => ts('Is this Country active?'),
322 'where' => 'civicrm_country.is_active',
324 'table_name' => 'civicrm_country',
325 'entity' => 'Country',
326 'bao' => 'CRM_Core_BAO_Country',
331 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
333 return Civi
::$statics[__CLASS__
]['fields'];
337 * Return a mapping from field-name to the corresponding key (as used in fields()).
340 * Array(string $name => string $uniqueName).
342 public static function &fieldKeys() {
343 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
344 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
346 return Civi
::$statics[__CLASS__
]['fieldKeys'];
350 * Returns the names of this table
354 public static function getTableName() {
355 return self
::$_tableName;
359 * Returns if this table needs to be logged
363 public function getLog() {
368 * Returns the list of fields that can be imported
370 * @param bool $prefix
374 public static function &import($prefix = FALSE) {
375 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'country', $prefix, []);
380 * Returns the list of fields that can be exported
382 * @param bool $prefix
386 public static function &export($prefix = FALSE) {
387 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'country', $prefix, []);
392 * Returns the list of indices
394 * @param bool $localize
398 public static function indices($localize = TRUE) {
400 'UI_name_iso_code' => [
401 'name' => 'UI_name_iso_code',
406 'localizable' => FALSE,
408 'sig' => 'civicrm_country::1::name::iso_code',
411 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;