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:cdd80b394924586274cf4b91183d3637)
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 public static function getEntityTitle() {
108 return ts('Countries');
112 * Returns foreign keys and entity references.
115 * [CRM_Core_Reference_Interface]
117 public static function getReferenceColumns() {
118 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
119 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
120 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'address_format_id', 'civicrm_address_format', 'id');
121 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'region_id', 'civicrm_worldregion', 'id');
122 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
124 return Civi
::$statics[__CLASS__
]['links'];
128 * Returns all the column names of this table
132 public static function &fields() {
133 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
134 Civi
::$statics[__CLASS__
]['fields'] = [
137 'type' => CRM_Utils_Type
::T_INT
,
138 'title' => ts('Country ID'),
139 'description' => ts('Country Id'),
141 'where' => 'civicrm_country.id',
142 'table_name' => 'civicrm_country',
143 'entity' => 'Country',
144 'bao' => 'CRM_Core_BAO_Country',
150 'type' => CRM_Utils_Type
::T_STRING
,
151 'title' => ts('Country'),
152 'description' => ts('Country Name'),
154 'size' => CRM_Utils_Type
::BIG
,
156 'where' => 'civicrm_country.name',
157 'headerPattern' => '/country/i',
158 'dataPattern' => '/^[A-Z][a-z]+\.?(\s+[A-Z][a-z]+){0,3}$/',
160 'table_name' => 'civicrm_country',
161 'entity' => 'Country',
162 'bao' => 'CRM_Core_BAO_Country',
167 'name' => 'iso_code',
168 'type' => CRM_Utils_Type
::T_STRING
,
169 'title' => ts('Country ISO Code'),
170 'description' => ts('ISO Code'),
172 'size' => CRM_Utils_Type
::TWO
,
173 'where' => 'civicrm_country.iso_code',
174 'table_name' => 'civicrm_country',
175 'entity' => 'Country',
176 'bao' => 'CRM_Core_BAO_Country',
181 'name' => 'country_code',
182 'type' => CRM_Utils_Type
::T_STRING
,
183 'title' => ts('Country Phone Prefix'),
184 'description' => ts('National prefix to be used when dialing TO this country.'),
186 'size' => CRM_Utils_Type
::FOUR
,
187 'where' => 'civicrm_country.country_code',
188 'table_name' => 'civicrm_country',
189 'entity' => 'Country',
190 'bao' => 'CRM_Core_BAO_Country',
194 'address_format_id' => [
195 'name' => 'address_format_id',
196 'type' => CRM_Utils_Type
::T_INT
,
197 'title' => ts('Address Format'),
198 'description' => ts('Foreign key to civicrm_address_format.id.'),
199 'where' => 'civicrm_country.address_format_id',
200 'table_name' => 'civicrm_country',
201 'entity' => 'Country',
202 'bao' => 'CRM_Core_BAO_Country',
204 'FKClassName' => 'CRM_Core_DAO_AddressFormat',
208 'name' => 'idd_prefix',
209 'type' => CRM_Utils_Type
::T_STRING
,
210 'title' => ts('Outgoing Phone Prefix'),
211 'description' => ts('International direct dialing prefix from within the country TO another country'),
213 'size' => CRM_Utils_Type
::FOUR
,
214 'where' => 'civicrm_country.idd_prefix',
215 'table_name' => 'civicrm_country',
216 'entity' => 'Country',
217 'bao' => 'CRM_Core_BAO_Country',
222 'name' => 'ndd_prefix',
223 'type' => CRM_Utils_Type
::T_STRING
,
224 'title' => ts('Area Code'),
225 'description' => ts('Access prefix to call within a country to a different area'),
227 'size' => CRM_Utils_Type
::FOUR
,
228 'where' => 'civicrm_country.ndd_prefix',
229 'table_name' => 'civicrm_country',
230 'entity' => 'Country',
231 'bao' => 'CRM_Core_BAO_Country',
236 'name' => 'region_id',
237 'type' => CRM_Utils_Type
::T_INT
,
238 'title' => ts('World Region ID'),
239 'description' => ts('Foreign key to civicrm_worldregion.id.'),
241 'where' => 'civicrm_country.region_id',
242 'table_name' => 'civicrm_country',
243 'entity' => 'Country',
244 'bao' => 'CRM_Core_BAO_Country',
246 'localize_context' => 'country',
247 'FKClassName' => 'CRM_Core_DAO_Worldregion',
248 'pseudoconstant' => [
249 'table' => 'civicrm_worldregion',
251 'labelColumn' => 'name',
255 'is_province_abbreviated' => [
256 'name' => 'is_province_abbreviated',
257 'type' => CRM_Utils_Type
::T_BOOLEAN
,
258 'title' => ts('Abbreviate Province?'),
259 'description' => ts('Should state/province be displayed as abbreviation for contacts from this country?'),
260 'where' => 'civicrm_country.is_province_abbreviated',
262 'table_name' => 'civicrm_country',
263 'entity' => 'Country',
264 'bao' => 'CRM_Core_BAO_Country',
269 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
271 return Civi
::$statics[__CLASS__
]['fields'];
275 * Return a mapping from field-name to the corresponding key (as used in fields()).
278 * Array(string $name => string $uniqueName).
280 public static function &fieldKeys() {
281 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
282 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
284 return Civi
::$statics[__CLASS__
]['fieldKeys'];
288 * Returns the names of this table
292 public static function getTableName() {
293 return self
::$_tableName;
297 * Returns if this table needs to be logged
301 public function getLog() {
306 * Returns the list of fields that can be imported
308 * @param bool $prefix
312 public static function &import($prefix = FALSE) {
313 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'country', $prefix, []);
318 * Returns the list of fields that can be exported
320 * @param bool $prefix
324 public static function &export($prefix = FALSE) {
325 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'country', $prefix, []);
330 * Returns the list of indices
332 * @param bool $localize
336 public static function indices($localize = TRUE) {
338 'UI_name_iso_code' => [
339 'name' => 'UI_name_iso_code',
344 'localizable' => FALSE,
346 'sig' => 'civicrm_country::1::name::iso_code',
349 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;