Fixed CRM-20330: provided a way to generate a table with a composite primary key...
[civicrm-core.git] / CRM / Core / DAO / Country.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
0f03f337 6| Copyright CiviCRM LLC (c) 2004-2017 |
e501603b
TO
7+--------------------------------------------------------------------+
8| This file is a part of CiviCRM. |
9| |
10| CiviCRM is free software; you can copy, modify, and distribute it |
11| under the terms of the GNU Affero General Public License |
12| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13| |
14| CiviCRM is distributed in the hope that it will be useful, but |
15| WITHOUT ANY WARRANTY; without even the implied warranty of |
16| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17| See the GNU Affero General Public License for more details. |
18| |
19| You should have received a copy of the GNU Affero General Public |
20| License and the CiviCRM Licensing Exception along |
21| with this program; if not, contact CiviCRM LLC |
22| at info[AT]civicrm[DOT]org. If you have questions about the |
23| GNU Affero General Public License or the licensing of CiviCRM, |
24| see the CiviCRM license FAQ at http://civicrm.org/licensing |
25+--------------------------------------------------------------------+
26*/
27/**
28 * @package CRM
0f03f337 29 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
30 *
31 * Generated from xml/schema/CRM/Core/Country.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
022785d8 33 * (GenCodeChecksum:a24c5ddeda39cc2efe1110845d0d9484)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
f41f0342 37/**
38 * CRM_Core_DAO_Country constructor.
39 */
e501603b
TO
40class CRM_Core_DAO_Country extends CRM_Core_DAO {
41 /**
f41f0342 42 * Static instance to hold the table name.
e501603b
TO
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_country';
e501603b 47 /**
f41f0342 48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b
TO
49 *
50 * @var boolean
51 */
52 static $_log = false;
53 /**
54 * Country Id
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * Country Name
61 *
62 * @var string
63 */
64 public $name;
65 /**
66 * ISO Code
67 *
68 * @var string
69 */
70 public $iso_code;
71 /**
72 * National prefix to be used when dialing TO this country.
73 *
74 * @var string
75 */
76 public $country_code;
77 /**
78 * Foreign key to civicrm_address_format.id.
79 *
80 * @var int unsigned
81 */
82 public $address_format_id;
83 /**
84 * International direct dialing prefix from within the country TO another country
85 *
86 * @var string
87 */
88 public $idd_prefix;
89 /**
90 * Access prefix to call within a country to a different area
91 *
92 * @var string
93 */
94 public $ndd_prefix;
95 /**
96 * Foreign key to civicrm_worldregion.id.
97 *
98 * @var int unsigned
99 */
100 public $region_id;
101 /**
102 * Should state/province be displayed as abbreviation for contacts from this country?
103 *
104 * @var boolean
105 */
106 public $is_province_abbreviated;
107 /**
f41f0342 108 * Class constructor.
e501603b
TO
109 */
110 function __construct() {
111 $this->__table = 'civicrm_country';
112 parent::__construct();
113 }
114 /**
f41f0342 115 * Returns foreign keys and entity references.
e501603b
TO
116 *
117 * @return array
118 * [CRM_Core_Reference_Interface]
119 */
120 static function getReferenceColumns() {
346aaaba
TO
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']);
e501603b 126 }
346aaaba 127 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
128 }
129 /**
130 * Returns all the column names of this table
131 *
132 * @return array
133 */
134 static function &fields() {
346aaaba
TO
135 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
136 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
137 'id' => array(
138 'name' => 'id',
139 'type' => CRM_Utils_Type::T_INT,
140 'title' => ts('Country ID') ,
141 'description' => 'Country Id',
142 'required' => true,
522a26c9 143 'table_name' => 'civicrm_country',
144 'entity' => 'Country',
145 'bao' => 'CRM_Core_BAO_Country',
e501603b
TO
146 ) ,
147 'name' => array(
148 'name' => 'name',
149 'type' => CRM_Utils_Type::T_STRING,
150 'title' => ts('Country') ,
151 'description' => 'Country Name',
152 'maxlength' => 64,
153 'size' => CRM_Utils_Type::BIG,
154 'import' => true,
155 'where' => 'civicrm_country.name',
156 'headerPattern' => '/country/i',
157 'dataPattern' => '/^[A-Z][a-z]+\.?(\s+[A-Z][a-z]+){0,3}$/',
158 'export' => true,
522a26c9 159 'table_name' => 'civicrm_country',
160 'entity' => 'Country',
161 'bao' => 'CRM_Core_BAO_Country',
e501603b
TO
162 ) ,
163 'iso_code' => array(
164 'name' => 'iso_code',
165 'type' => CRM_Utils_Type::T_STRING,
166 'title' => ts('Country ISO Code') ,
167 'description' => 'ISO Code',
168 'maxlength' => 2,
169 'size' => CRM_Utils_Type::TWO,
522a26c9 170 'table_name' => 'civicrm_country',
171 'entity' => 'Country',
172 'bao' => 'CRM_Core_BAO_Country',
e501603b
TO
173 ) ,
174 'country_code' => array(
175 'name' => 'country_code',
176 'type' => CRM_Utils_Type::T_STRING,
177 'title' => ts('Country Phone Prefix') ,
178 'description' => 'National prefix to be used when dialing TO this country.',
179 'maxlength' => 4,
180 'size' => CRM_Utils_Type::FOUR,
522a26c9 181 'table_name' => 'civicrm_country',
182 'entity' => 'Country',
183 'bao' => 'CRM_Core_BAO_Country',
e501603b
TO
184 ) ,
185 'address_format_id' => array(
186 'name' => 'address_format_id',
187 'type' => CRM_Utils_Type::T_INT,
188 'title' => ts('Address Format') ,
189 'description' => 'Foreign key to civicrm_address_format.id.',
522a26c9 190 'table_name' => 'civicrm_country',
191 'entity' => 'Country',
192 'bao' => 'CRM_Core_BAO_Country',
e501603b
TO
193 'FKClassName' => 'CRM_Core_DAO_AddressFormat',
194 ) ,
195 'idd_prefix' => array(
196 'name' => 'idd_prefix',
197 'type' => CRM_Utils_Type::T_STRING,
198 'title' => ts('Outgoing Phone Prefix') ,
199 'description' => 'International direct dialing prefix from within the country TO another country',
200 'maxlength' => 4,
201 'size' => CRM_Utils_Type::FOUR,
522a26c9 202 'table_name' => 'civicrm_country',
203 'entity' => 'Country',
204 'bao' => 'CRM_Core_BAO_Country',
e501603b
TO
205 ) ,
206 'ndd_prefix' => array(
207 'name' => 'ndd_prefix',
208 'type' => CRM_Utils_Type::T_STRING,
209 'title' => ts('Area Code') ,
210 'description' => 'Access prefix to call within a country to a different area',
211 'maxlength' => 4,
212 'size' => CRM_Utils_Type::FOUR,
522a26c9 213 'table_name' => 'civicrm_country',
214 'entity' => 'Country',
215 'bao' => 'CRM_Core_BAO_Country',
e501603b
TO
216 ) ,
217 'region_id' => array(
218 'name' => 'region_id',
219 'type' => CRM_Utils_Type::T_INT,
220 'title' => ts('Region') ,
221 'description' => 'Foreign key to civicrm_worldregion.id.',
222 'required' => true,
522a26c9 223 'table_name' => 'civicrm_country',
224 'entity' => 'Country',
225 'bao' => 'CRM_Core_BAO_Country',
e501603b
TO
226 'FKClassName' => 'CRM_Core_DAO_Worldregion',
227 ) ,
228 'is_province_abbreviated' => array(
229 'name' => 'is_province_abbreviated',
230 'type' => CRM_Utils_Type::T_BOOLEAN,
231 'title' => ts('Abbreviate Province?') ,
232 'description' => 'Should state/province be displayed as abbreviation for contacts from this country?',
522a26c9 233 'table_name' => 'civicrm_country',
234 'entity' => 'Country',
235 'bao' => 'CRM_Core_BAO_Country',
e501603b
TO
236 ) ,
237 );
346aaaba 238 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 239 }
346aaaba 240 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
241 }
242 /**
bd8e0b14 243 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
244 *
245 * @return array
bd8e0b14 246 * Array(string $name => string $uniqueName).
e501603b
TO
247 */
248 static function &fieldKeys() {
bd8e0b14
TO
249 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
250 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 251 }
bd8e0b14 252 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
253 }
254 /**
255 * Returns the names of this table
256 *
257 * @return string
258 */
259 static function getTableName() {
260 return self::$_tableName;
261 }
262 /**
263 * Returns if this table needs to be logged
264 *
265 * @return boolean
266 */
267 function getLog() {
268 return self::$_log;
269 }
270 /**
271 * Returns the list of fields that can be imported
272 *
273 * @param bool $prefix
274 *
275 * @return array
276 */
277 static function &import($prefix = false) {
60808919
TO
278 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'country', $prefix, array());
279 return $r;
e501603b
TO
280 }
281 /**
282 * Returns the list of fields that can be exported
283 *
284 * @param bool $prefix
285 *
286 * @return array
287 */
288 static function &export($prefix = false) {
60808919
TO
289 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'country', $prefix, array());
290 return $r;
e501603b
TO
291 }
292}