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:0e0ebf773f04ad229c4165fe05f63345)
13 * Database access object for the Country entity.
15 class CRM_Core_DAO_Country
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_country';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = FALSE;
53 * National prefix to be used when dialing TO this country.
60 * Foreign key to civicrm_address_format.id.
64 public $address_format_id;
67 * International direct dialing prefix from within the country TO another country
74 * Access prefix to call within a country to a different area
81 * Foreign key to civicrm_worldregion.id.
88 * Should state/province be displayed as abbreviation for contacts from this country?
92 public $is_province_abbreviated;
97 public function __construct() {
98 $this->__table
= 'civicrm_country';
99 parent
::__construct();
103 * Returns localized title of this entity.
105 public static function getEntityTitle() {
106 return ts('Countries');
110 * Returns foreign keys and entity references.
113 * [CRM_Core_Reference_Interface]
115 public static function getReferenceColumns() {
116 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
117 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
118 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'address_format_id', 'civicrm_address_format', 'id');
119 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'region_id', 'civicrm_worldregion', 'id');
120 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
122 return Civi
::$statics[__CLASS__
]['links'];
126 * Returns all the column names of this table
130 public static function &fields() {
131 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
132 Civi
::$statics[__CLASS__
]['fields'] = [
135 'type' => CRM_Utils_Type
::T_INT
,
136 'title' => ts('Country ID'),
137 'description' => ts('Country Id'),
139 'where' => 'civicrm_country.id',
140 'table_name' => 'civicrm_country',
141 'entity' => 'Country',
142 'bao' => 'CRM_Core_BAO_Country',
147 'type' => CRM_Utils_Type
::T_STRING
,
148 'title' => ts('Country'),
149 'description' => ts('Country Name'),
151 'size' => CRM_Utils_Type
::BIG
,
153 'where' => 'civicrm_country.name',
154 'headerPattern' => '/country/i',
155 'dataPattern' => '/^[A-Z][a-z]+\.?(\s+[A-Z][a-z]+){0,3}$/',
157 'table_name' => 'civicrm_country',
158 'entity' => 'Country',
159 'bao' => 'CRM_Core_BAO_Country',
163 'name' => 'iso_code',
164 'type' => CRM_Utils_Type
::T_STRING
,
165 'title' => ts('Country ISO Code'),
166 'description' => ts('ISO Code'),
168 'size' => CRM_Utils_Type
::TWO
,
169 'where' => 'civicrm_country.iso_code',
170 'table_name' => 'civicrm_country',
171 'entity' => 'Country',
172 'bao' => 'CRM_Core_BAO_Country',
176 'name' => 'country_code',
177 'type' => CRM_Utils_Type
::T_STRING
,
178 'title' => ts('Country Phone Prefix'),
179 'description' => ts('National prefix to be used when dialing TO this country.'),
181 'size' => CRM_Utils_Type
::FOUR
,
182 'where' => 'civicrm_country.country_code',
183 'table_name' => 'civicrm_country',
184 'entity' => 'Country',
185 'bao' => 'CRM_Core_BAO_Country',
188 'address_format_id' => [
189 'name' => 'address_format_id',
190 'type' => CRM_Utils_Type
::T_INT
,
191 'title' => ts('Address Format'),
192 'description' => ts('Foreign key to civicrm_address_format.id.'),
193 'where' => 'civicrm_country.address_format_id',
194 'table_name' => 'civicrm_country',
195 'entity' => 'Country',
196 'bao' => 'CRM_Core_BAO_Country',
198 'FKClassName' => 'CRM_Core_DAO_AddressFormat',
201 'name' => 'idd_prefix',
202 'type' => CRM_Utils_Type
::T_STRING
,
203 'title' => ts('Outgoing Phone Prefix'),
204 'description' => ts('International direct dialing prefix from within the country TO another country'),
206 'size' => CRM_Utils_Type
::FOUR
,
207 'where' => 'civicrm_country.idd_prefix',
208 'table_name' => 'civicrm_country',
209 'entity' => 'Country',
210 'bao' => 'CRM_Core_BAO_Country',
214 'name' => 'ndd_prefix',
215 'type' => CRM_Utils_Type
::T_STRING
,
216 'title' => ts('Area Code'),
217 'description' => ts('Access prefix to call within a country to a different area'),
219 'size' => CRM_Utils_Type
::FOUR
,
220 'where' => 'civicrm_country.ndd_prefix',
221 'table_name' => 'civicrm_country',
222 'entity' => 'Country',
223 'bao' => 'CRM_Core_BAO_Country',
227 'name' => 'region_id',
228 'type' => CRM_Utils_Type
::T_INT
,
229 'title' => ts('World Region ID'),
230 'description' => ts('Foreign key to civicrm_worldregion.id.'),
232 'where' => 'civicrm_country.region_id',
233 'table_name' => 'civicrm_country',
234 'entity' => 'Country',
235 'bao' => 'CRM_Core_BAO_Country',
237 'localize_context' => 'country',
238 'FKClassName' => 'CRM_Core_DAO_Worldregion',
239 'pseudoconstant' => [
240 'table' => 'civicrm_worldregion',
242 'labelColumn' => 'name',
245 'is_province_abbreviated' => [
246 'name' => 'is_province_abbreviated',
247 'type' => CRM_Utils_Type
::T_BOOLEAN
,
248 'title' => ts('Abbreviate Province?'),
249 'description' => ts('Should state/province be displayed as abbreviation for contacts from this country?'),
250 'where' => 'civicrm_country.is_province_abbreviated',
252 'table_name' => 'civicrm_country',
253 'entity' => 'Country',
254 'bao' => 'CRM_Core_BAO_Country',
258 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
260 return Civi
::$statics[__CLASS__
]['fields'];
264 * Return a mapping from field-name to the corresponding key (as used in fields()).
267 * Array(string $name => string $uniqueName).
269 public static function &fieldKeys() {
270 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
271 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
273 return Civi
::$statics[__CLASS__
]['fieldKeys'];
277 * Returns the names of this table
281 public static function getTableName() {
282 return self
::$_tableName;
286 * Returns if this table needs to be logged
290 public function getLog() {
295 * Returns the list of fields that can be imported
297 * @param bool $prefix
301 public static function &import($prefix = FALSE) {
302 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'country', $prefix, []);
307 * Returns the list of fields that can be exported
309 * @param bool $prefix
313 public static function &export($prefix = FALSE) {
314 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'country', $prefix, []);
319 * Returns the list of indices
321 * @param bool $localize
325 public static function indices($localize = TRUE) {
327 'UI_name_iso_code' => [
328 'name' => 'UI_name_iso_code',
333 'localizable' => FALSE,
335 'sig' => 'civicrm_country::1::name::iso_code',
338 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;