API/DAO Metadata - Retain versioning metadata for possible usage in runtime+tooling
[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:22bfd6264c17c80a3638b9860cb97767)
10 */
11
12 /**
13 * Database access object for the StateProvince entity.
14 */
15 class CRM_Core_DAO_StateProvince extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_state_province';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 public static $_log = FALSE;
30
31 /**
32 * State/Province ID
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * Name of State/Province
40 *
41 * @var string
42 */
43 public $name;
44
45 /**
46 * 2-4 Character Abbreviation of State/Province
47 *
48 * @var string
49 */
50 public $abbreviation;
51
52 /**
53 * ID of Country that State/Province belong
54 *
55 * @var int
56 */
57 public $country_id;
58
59 /**
60 * Class constructor.
61 */
62 public function __construct() {
63 $this->__table = 'civicrm_state_province';
64 parent::__construct();
65 }
66
67 /**
68 * Returns localized title of this entity.
69 */
70 public static function getEntityTitle() {
71 return ts('State Provinces');
72 }
73
74 /**
75 * Returns foreign keys and entity references.
76 *
77 * @return array
78 * [CRM_Core_Reference_Interface]
79 */
80 public static function getReferenceColumns() {
81 if (!isset(Civi::$statics[__CLASS__]['links'])) {
82 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
83 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'country_id', 'civicrm_country', 'id');
84 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
85 }
86 return Civi::$statics[__CLASS__]['links'];
87 }
88
89 /**
90 * Returns all the column names of this table
91 *
92 * @return array
93 */
94 public static function &fields() {
95 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
96 Civi::$statics[__CLASS__]['fields'] = [
97 'id' => [
98 'name' => 'id',
99 'type' => CRM_Utils_Type::T_INT,
100 'title' => ts('State ID'),
101 'description' => ts('State/Province ID'),
102 'required' => TRUE,
103 'where' => 'civicrm_state_province.id',
104 'table_name' => 'civicrm_state_province',
105 'entity' => 'StateProvince',
106 'bao' => 'CRM_Core_DAO_StateProvince',
107 'localizable' => 0,
108 'add' => '1.1',
109 ],
110 'name' => [
111 'name' => 'name',
112 'type' => CRM_Utils_Type::T_STRING,
113 'title' => ts('State'),
114 'description' => ts('Name of State/Province'),
115 'maxlength' => 64,
116 'size' => CRM_Utils_Type::BIG,
117 'import' => TRUE,
118 'where' => 'civicrm_state_province.name',
119 'headerPattern' => '/state|prov(ince)?/i',
120 'dataPattern' => '/[A-Z]{2}/',
121 'export' => TRUE,
122 'table_name' => 'civicrm_state_province',
123 'entity' => 'StateProvince',
124 'bao' => 'CRM_Core_DAO_StateProvince',
125 'localizable' => 0,
126 'add' => '1.1',
127 ],
128 'abbreviation' => [
129 'name' => 'abbreviation',
130 'type' => CRM_Utils_Type::T_STRING,
131 'title' => ts('State Abbreviation'),
132 'description' => ts('2-4 Character Abbreviation of State/Province'),
133 'maxlength' => 4,
134 'size' => CRM_Utils_Type::FOUR,
135 'where' => 'civicrm_state_province.abbreviation',
136 'table_name' => 'civicrm_state_province',
137 'entity' => 'StateProvince',
138 'bao' => 'CRM_Core_DAO_StateProvince',
139 'localizable' => 0,
140 'add' => '1.1',
141 ],
142 'country_id' => [
143 'name' => 'country_id',
144 'type' => CRM_Utils_Type::T_INT,
145 'title' => ts('Country'),
146 'description' => ts('ID of Country that State/Province belong'),
147 'required' => TRUE,
148 'where' => 'civicrm_state_province.country_id',
149 'table_name' => 'civicrm_state_province',
150 'entity' => 'StateProvince',
151 'bao' => 'CRM_Core_DAO_StateProvince',
152 'localizable' => 0,
153 'FKClassName' => 'CRM_Core_DAO_Country',
154 'add' => '1.1',
155 ],
156 ];
157 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
158 }
159 return Civi::$statics[__CLASS__]['fields'];
160 }
161
162 /**
163 * Return a mapping from field-name to the corresponding key (as used in fields()).
164 *
165 * @return array
166 * Array(string $name => string $uniqueName).
167 */
168 public static function &fieldKeys() {
169 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
170 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
171 }
172 return Civi::$statics[__CLASS__]['fieldKeys'];
173 }
174
175 /**
176 * Returns the names of this table
177 *
178 * @return string
179 */
180 public static function getTableName() {
181 return self::$_tableName;
182 }
183
184 /**
185 * Returns if this table needs to be logged
186 *
187 * @return bool
188 */
189 public function getLog() {
190 return self::$_log;
191 }
192
193 /**
194 * Returns the list of fields that can be imported
195 *
196 * @param bool $prefix
197 *
198 * @return array
199 */
200 public static function &import($prefix = FALSE) {
201 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'state_province', $prefix, []);
202 return $r;
203 }
204
205 /**
206 * Returns the list of fields that can be exported
207 *
208 * @param bool $prefix
209 *
210 * @return array
211 */
212 public static function &export($prefix = FALSE) {
213 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'state_province', $prefix, []);
214 return $r;
215 }
216
217 /**
218 * Returns the list of indices
219 *
220 * @param bool $localize
221 *
222 * @return array
223 */
224 public static function indices($localize = TRUE) {
225 $indices = [
226 'UI_name_country_id' => [
227 'name' => 'UI_name_country_id',
228 'field' => [
229 0 => 'name',
230 1 => 'country_id',
231 ],
232 'localizable' => FALSE,
233 'unique' => TRUE,
234 'sig' => 'civicrm_state_province::1::name::country_id',
235 ],
236 ];
237 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
238 }
239
240 }