Merge pull request #23825 from colemanw/profileExport
[civicrm-core.git] / CRM / Core / DAO / StateProvince.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/StateProvince.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:b52f997bf6a08f0408c349a0ef187779)
10 */
11
12 /**
13 * Database access object for the StateProvince entity.
14 */
15 class CRM_Core_DAO_StateProvince extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_state_province';
25
26 /**
27 * Field to show when displaying a record.
28 *
29 * @var string
30 */
31 public static $_labelField = 'name';
32
33 /**
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
35 *
36 * @var bool
37 */
38 public static $_log = FALSE;
39
40 /**
41 * State/Province ID
42 *
43 * @var int|string|null
44 * (SQL type: int unsigned)
45 * Note that values will be retrieved from the database as a string.
46 */
47 public $id;
48
49 /**
50 * Name of State/Province
51 *
52 * @var string|null
53 * (SQL type: varchar(64))
54 * Note that values will be retrieved from the database as a string.
55 */
56 public $name;
57
58 /**
59 * 2-4 Character Abbreviation of State/Province
60 *
61 * @var string|null
62 * (SQL type: varchar(4))
63 * Note that values will be retrieved from the database as a string.
64 */
65 public $abbreviation;
66
67 /**
68 * ID of Country that State/Province belong
69 *
70 * @var int|string
71 * (SQL type: int unsigned)
72 * Note that values will be retrieved from the database as a string.
73 */
74 public $country_id;
75
76 /**
77 * Is this StateProvince active?
78 *
79 * @var bool|string
80 * (SQL type: tinyint)
81 * Note that values will be retrieved from the database as a string.
82 */
83 public $is_active;
84
85 /**
86 * Class constructor.
87 */
88 public function __construct() {
89 $this->__table = 'civicrm_state_province';
90 parent::__construct();
91 }
92
93 /**
94 * Returns localized title of this entity.
95 *
96 * @param bool $plural
97 * Whether to return the plural version of the title.
98 */
99 public static function getEntityTitle($plural = FALSE) {
100 return $plural ? ts('States/Provinces') : ts('State/Province');
101 }
102
103 /**
104 * Returns foreign keys and entity references.
105 *
106 * @return array
107 * [CRM_Core_Reference_Interface]
108 */
109 public static function getReferenceColumns() {
110 if (!isset(Civi::$statics[__CLASS__]['links'])) {
111 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
112 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'country_id', 'civicrm_country', 'id');
113 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
114 }
115 return Civi::$statics[__CLASS__]['links'];
116 }
117
118 /**
119 * Returns all the column names of this table
120 *
121 * @return array
122 */
123 public static function &fields() {
124 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
125 Civi::$statics[__CLASS__]['fields'] = [
126 'id' => [
127 'name' => 'id',
128 'type' => CRM_Utils_Type::T_INT,
129 'title' => ts('State ID'),
130 'description' => ts('State/Province ID'),
131 'required' => TRUE,
132 'where' => 'civicrm_state_province.id',
133 'table_name' => 'civicrm_state_province',
134 'entity' => 'StateProvince',
135 'bao' => 'CRM_Core_DAO_StateProvince',
136 'localizable' => 0,
137 'html' => [
138 'type' => 'Number',
139 ],
140 'readonly' => TRUE,
141 'add' => '1.1',
142 ],
143 'name' => [
144 'name' => 'name',
145 'type' => CRM_Utils_Type::T_STRING,
146 'title' => ts('State'),
147 'description' => ts('Name of State/Province'),
148 'maxlength' => 64,
149 'size' => CRM_Utils_Type::BIG,
150 'import' => TRUE,
151 'where' => 'civicrm_state_province.name',
152 'headerPattern' => '/state|prov(ince)?/i',
153 'dataPattern' => '/[A-Z]{2}/',
154 'export' => TRUE,
155 'table_name' => 'civicrm_state_province',
156 'entity' => 'StateProvince',
157 'bao' => 'CRM_Core_DAO_StateProvince',
158 'localizable' => 0,
159 'add' => '1.1',
160 ],
161 'abbreviation' => [
162 'name' => 'abbreviation',
163 'type' => CRM_Utils_Type::T_STRING,
164 'title' => ts('State Abbreviation'),
165 'description' => ts('2-4 Character Abbreviation of State/Province'),
166 'maxlength' => 4,
167 'size' => CRM_Utils_Type::FOUR,
168 'where' => 'civicrm_state_province.abbreviation',
169 'table_name' => 'civicrm_state_province',
170 'entity' => 'StateProvince',
171 'bao' => 'CRM_Core_DAO_StateProvince',
172 'localizable' => 0,
173 'add' => '1.1',
174 ],
175 'country_id' => [
176 'name' => 'country_id',
177 'type' => CRM_Utils_Type::T_INT,
178 'title' => ts('Country ID'),
179 'description' => ts('ID of Country that State/Province belong'),
180 'required' => TRUE,
181 'where' => 'civicrm_state_province.country_id',
182 'table_name' => 'civicrm_state_province',
183 'entity' => 'StateProvince',
184 'bao' => 'CRM_Core_DAO_StateProvince',
185 'localizable' => 0,
186 'FKClassName' => 'CRM_Core_DAO_Country',
187 'html' => [
188 'label' => ts("Country"),
189 ],
190 'add' => '1.1',
191 ],
192 'is_active' => [
193 'name' => 'is_active',
194 'type' => CRM_Utils_Type::T_BOOLEAN,
195 'title' => ts('StateProvince Is Active'),
196 'description' => ts('Is this StateProvince active?'),
197 'required' => TRUE,
198 'where' => 'civicrm_state_province.is_active',
199 'default' => '1',
200 'table_name' => 'civicrm_state_province',
201 'entity' => 'StateProvince',
202 'bao' => 'CRM_Core_DAO_StateProvince',
203 'localizable' => 0,
204 'add' => '5.35',
205 ],
206 ];
207 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
208 }
209 return Civi::$statics[__CLASS__]['fields'];
210 }
211
212 /**
213 * Return a mapping from field-name to the corresponding key (as used in fields()).
214 *
215 * @return array
216 * Array(string $name => string $uniqueName).
217 */
218 public static function &fieldKeys() {
219 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
220 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
221 }
222 return Civi::$statics[__CLASS__]['fieldKeys'];
223 }
224
225 /**
226 * Returns the names of this table
227 *
228 * @return string
229 */
230 public static function getTableName() {
231 return self::$_tableName;
232 }
233
234 /**
235 * Returns if this table needs to be logged
236 *
237 * @return bool
238 */
239 public function getLog() {
240 return self::$_log;
241 }
242
243 /**
244 * Returns the list of fields that can be imported
245 *
246 * @param bool $prefix
247 *
248 * @return array
249 */
250 public static function &import($prefix = FALSE) {
251 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'state_province', $prefix, []);
252 return $r;
253 }
254
255 /**
256 * Returns the list of fields that can be exported
257 *
258 * @param bool $prefix
259 *
260 * @return array
261 */
262 public static function &export($prefix = FALSE) {
263 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'state_province', $prefix, []);
264 return $r;
265 }
266
267 /**
268 * Returns the list of indices
269 *
270 * @param bool $localize
271 *
272 * @return array
273 */
274 public static function indices($localize = TRUE) {
275 $indices = [
276 'UI_name_country_id' => [
277 'name' => 'UI_name_country_id',
278 'field' => [
279 0 => 'name',
280 1 => 'country_id',
281 ],
282 'localizable' => FALSE,
283 'unique' => TRUE,
284 'sig' => 'civicrm_state_province::1::name::country_id',
285 ],
286 ];
287 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
288 }
289
290 }