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:2215bb79c9fe62c60700f232598a9462)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = FALSE;
55 * National prefix to be used when dialing TO this country.
62 * Foreign key to civicrm_address_format.id.
66 public $address_format_id;
69 * International direct dialing prefix from within the country TO another country
76 * Access prefix to call within a country to a different area
83 * Foreign key to civicrm_worldregion.id.
90 * Should state/province be displayed as abbreviation for contacts from this country?
94 public $is_province_abbreviated;
99 public function __construct() {
100 $this->__table
= 'civicrm_country';
101 parent
::__construct();
105 * Returns localized title of this entity.
107 * @param bool $plural
108 * Whether to return the plural version of the title.
110 public static function getEntityTitle($plural = FALSE) {
111 return $plural ?
ts('Countries') : ts('Country');
115 * Returns foreign keys and entity references.
118 * [CRM_Core_Reference_Interface]
120 public static function getReferenceColumns() {
121 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
122 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
123 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'address_format_id', 'civicrm_address_format', 'id');
124 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'region_id', 'civicrm_worldregion', 'id');
125 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
127 return Civi
::$statics[__CLASS__
]['links'];
131 * Returns all the column names of this table
135 public static function &fields() {
136 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
137 Civi
::$statics[__CLASS__
]['fields'] = [
140 'type' => CRM_Utils_Type
::T_INT
,
141 'title' => ts('Country ID'),
142 'description' => ts('Country Id'),
144 'where' => 'civicrm_country.id',
145 'table_name' => 'civicrm_country',
146 'entity' => 'Country',
147 'bao' => 'CRM_Core_BAO_Country',
153 'type' => CRM_Utils_Type
::T_STRING
,
154 'title' => ts('Country'),
155 'description' => ts('Country Name'),
157 'size' => CRM_Utils_Type
::BIG
,
159 'where' => 'civicrm_country.name',
160 'headerPattern' => '/country/i',
161 'dataPattern' => '/^[A-Z][a-z]+\.?(\s+[A-Z][a-z]+){0,3}$/',
163 'table_name' => 'civicrm_country',
164 'entity' => 'Country',
165 'bao' => 'CRM_Core_BAO_Country',
170 'name' => 'iso_code',
171 'type' => CRM_Utils_Type
::T_STRING
,
172 'title' => ts('Country ISO Code'),
173 'description' => ts('ISO Code'),
175 'size' => CRM_Utils_Type
::TWO
,
176 'where' => 'civicrm_country.iso_code',
177 'table_name' => 'civicrm_country',
178 'entity' => 'Country',
179 'bao' => 'CRM_Core_BAO_Country',
184 'name' => 'country_code',
185 'type' => CRM_Utils_Type
::T_STRING
,
186 'title' => ts('Country Phone Prefix'),
187 'description' => ts('National prefix to be used when dialing TO this country.'),
189 'size' => CRM_Utils_Type
::FOUR
,
190 'where' => 'civicrm_country.country_code',
191 'table_name' => 'civicrm_country',
192 'entity' => 'Country',
193 'bao' => 'CRM_Core_BAO_Country',
197 'address_format_id' => [
198 'name' => 'address_format_id',
199 'type' => CRM_Utils_Type
::T_INT
,
200 'title' => ts('Address Format'),
201 'description' => ts('Foreign key to civicrm_address_format.id.'),
202 'where' => 'civicrm_country.address_format_id',
203 'table_name' => 'civicrm_country',
204 'entity' => 'Country',
205 'bao' => 'CRM_Core_BAO_Country',
207 'FKClassName' => 'CRM_Core_DAO_AddressFormat',
211 'name' => 'idd_prefix',
212 'type' => CRM_Utils_Type
::T_STRING
,
213 'title' => ts('Outgoing Phone Prefix'),
214 'description' => ts('International direct dialing prefix from within the country TO another country'),
216 'size' => CRM_Utils_Type
::FOUR
,
217 'where' => 'civicrm_country.idd_prefix',
218 'table_name' => 'civicrm_country',
219 'entity' => 'Country',
220 'bao' => 'CRM_Core_BAO_Country',
225 'name' => 'ndd_prefix',
226 'type' => CRM_Utils_Type
::T_STRING
,
227 'title' => ts('Area Code'),
228 'description' => ts('Access prefix to call within a country to a different area'),
230 'size' => CRM_Utils_Type
::FOUR
,
231 'where' => 'civicrm_country.ndd_prefix',
232 'table_name' => 'civicrm_country',
233 'entity' => 'Country',
234 'bao' => 'CRM_Core_BAO_Country',
239 'name' => 'region_id',
240 'type' => CRM_Utils_Type
::T_INT
,
241 'title' => ts('World Region ID'),
242 'description' => ts('Foreign key to civicrm_worldregion.id.'),
244 'where' => 'civicrm_country.region_id',
245 'table_name' => 'civicrm_country',
246 'entity' => 'Country',
247 'bao' => 'CRM_Core_BAO_Country',
249 'localize_context' => 'country',
250 'FKClassName' => 'CRM_Core_DAO_Worldregion',
251 'pseudoconstant' => [
252 'table' => 'civicrm_worldregion',
254 'labelColumn' => 'name',
258 'is_province_abbreviated' => [
259 'name' => 'is_province_abbreviated',
260 'type' => CRM_Utils_Type
::T_BOOLEAN
,
261 'title' => ts('Abbreviate Province?'),
262 'description' => ts('Should state/province be displayed as abbreviation for contacts from this country?'),
263 'where' => 'civicrm_country.is_province_abbreviated',
265 'table_name' => 'civicrm_country',
266 'entity' => 'Country',
267 'bao' => 'CRM_Core_BAO_Country',
272 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
274 return Civi
::$statics[__CLASS__
]['fields'];
278 * Return a mapping from field-name to the corresponding key (as used in fields()).
281 * Array(string $name => string $uniqueName).
283 public static function &fieldKeys() {
284 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
285 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
287 return Civi
::$statics[__CLASS__
]['fieldKeys'];
291 * Returns the names of this table
295 public static function getTableName() {
296 return self
::$_tableName;
300 * Returns if this table needs to be logged
304 public function getLog() {
309 * Returns the list of fields that can be imported
311 * @param bool $prefix
315 public static function &import($prefix = FALSE) {
316 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'country', $prefix, []);
321 * Returns the list of fields that can be exported
323 * @param bool $prefix
327 public static function &export($prefix = FALSE) {
328 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'country', $prefix, []);
333 * Returns the list of indices
335 * @param bool $localize
339 public static function indices($localize = TRUE) {
341 'UI_name_iso_code' => [
342 'name' => 'UI_name_iso_code',
347 'localizable' => FALSE,
349 'sig' => 'civicrm_country::1::name::iso_code',
352 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;