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