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:680f4faa9e939df6f6c4ba3f1efd7853)
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',
171 'type' => CRM_Utils_Type
::T_STRING
,
172 'title' => ts('Country'),
173 'description' => ts('Country Name'),
175 'size' => CRM_Utils_Type
::BIG
,
177 'where' => 'civicrm_country.name',
178 'headerPattern' => '/country/i',
179 'dataPattern' => '/^[A-Z][a-z]+\.?(\s+[A-Z][a-z]+){0,3}$/',
181 'table_name' => 'civicrm_country',
182 'entity' => 'Country',
183 'bao' => 'CRM_Core_BAO_Country',
188 'name' => 'iso_code',
189 'type' => CRM_Utils_Type
::T_STRING
,
190 'title' => ts('Country ISO Code'),
191 'description' => ts('ISO Code'),
193 'size' => CRM_Utils_Type
::TWO
,
194 'where' => 'civicrm_country.iso_code',
195 'table_name' => 'civicrm_country',
196 'entity' => 'Country',
197 'bao' => 'CRM_Core_BAO_Country',
202 'name' => 'country_code',
203 'type' => CRM_Utils_Type
::T_STRING
,
204 'title' => ts('Country Phone Prefix'),
205 'description' => ts('National prefix to be used when dialing TO this country.'),
207 'size' => CRM_Utils_Type
::FOUR
,
208 'where' => 'civicrm_country.country_code',
209 'table_name' => 'civicrm_country',
210 'entity' => 'Country',
211 'bao' => 'CRM_Core_BAO_Country',
215 'address_format_id' => [
216 'name' => 'address_format_id',
217 'type' => CRM_Utils_Type
::T_INT
,
218 'title' => ts('Address Format ID'),
219 'description' => ts('Foreign key to civicrm_address_format.id.'),
220 'where' => 'civicrm_country.address_format_id',
221 'table_name' => 'civicrm_country',
222 'entity' => 'Country',
223 'bao' => 'CRM_Core_BAO_Country',
225 'FKClassName' => 'CRM_Core_DAO_AddressFormat',
227 'label' => ts("Address Format"),
232 'name' => 'idd_prefix',
233 'type' => CRM_Utils_Type
::T_STRING
,
234 'title' => ts('Outgoing Phone Prefix'),
235 'description' => ts('International direct dialing prefix from within the country TO another country'),
237 'size' => CRM_Utils_Type
::FOUR
,
238 'where' => 'civicrm_country.idd_prefix',
239 'table_name' => 'civicrm_country',
240 'entity' => 'Country',
241 'bao' => 'CRM_Core_BAO_Country',
246 'name' => 'ndd_prefix',
247 'type' => CRM_Utils_Type
::T_STRING
,
248 'title' => ts('Area Code'),
249 'description' => ts('Access prefix to call within a country to a different area'),
251 'size' => CRM_Utils_Type
::FOUR
,
252 'where' => 'civicrm_country.ndd_prefix',
253 'table_name' => 'civicrm_country',
254 'entity' => 'Country',
255 'bao' => 'CRM_Core_BAO_Country',
260 'name' => 'region_id',
261 'type' => CRM_Utils_Type
::T_INT
,
262 'title' => ts('World Region ID'),
263 'description' => ts('Foreign key to civicrm_worldregion.id.'),
265 'where' => 'civicrm_country.region_id',
266 'table_name' => 'civicrm_country',
267 'entity' => 'Country',
268 'bao' => 'CRM_Core_BAO_Country',
270 'localize_context' => 'country',
271 'FKClassName' => 'CRM_Core_DAO_Worldregion',
273 'label' => ts("World Region"),
275 'pseudoconstant' => [
276 'table' => 'civicrm_worldregion',
278 'labelColumn' => 'name',
282 'is_province_abbreviated' => [
283 'name' => 'is_province_abbreviated',
284 'type' => CRM_Utils_Type
::T_BOOLEAN
,
285 'title' => ts('Abbreviate Province?'),
286 'description' => ts('Should state/province be displayed as abbreviation for contacts from this country?'),
287 'where' => 'civicrm_country.is_province_abbreviated',
289 'table_name' => 'civicrm_country',
290 'entity' => 'Country',
291 'bao' => 'CRM_Core_BAO_Country',
296 'name' => 'is_active',
297 'type' => CRM_Utils_Type
::T_BOOLEAN
,
298 'title' => ts('Country Is Active'),
299 'description' => ts('Is this Country active?'),
300 'where' => 'civicrm_country.is_active',
302 'table_name' => 'civicrm_country',
303 'entity' => 'Country',
304 'bao' => 'CRM_Core_BAO_Country',
309 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
311 return Civi
::$statics[__CLASS__
]['fields'];
315 * Return a mapping from field-name to the corresponding key (as used in fields()).
318 * Array(string $name => string $uniqueName).
320 public static function &fieldKeys() {
321 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
322 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
324 return Civi
::$statics[__CLASS__
]['fieldKeys'];
328 * Returns the names of this table
332 public static function getTableName() {
333 return self
::$_tableName;
337 * Returns if this table needs to be logged
341 public function getLog() {
346 * Returns the list of fields that can be imported
348 * @param bool $prefix
352 public static function &import($prefix = FALSE) {
353 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'country', $prefix, []);
358 * Returns the list of fields that can be exported
360 * @param bool $prefix
364 public static function &export($prefix = FALSE) {
365 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'country', $prefix, []);
370 * Returns the list of indices
372 * @param bool $localize
376 public static function indices($localize = TRUE) {
378 'UI_name_iso_code' => [
379 'name' => 'UI_name_iso_code',
384 'localizable' => FALSE,
386 'sig' => 'civicrm_country::1::name::iso_code',
389 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;