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 | |
c1e814c7 | 9 | * (GenCodeChecksum:b52f997bf6a08f0408c349a0ef187779) |
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 | * | |
28979d65 CW |
43 | * @var int|string|null |
44 | * (SQL type: int unsigned) | |
45 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
46 | */ |
47 | public $id; | |
c3fc2621 | 48 | |
e501603b TO |
49 | /** |
50 | * Name of State/Province | |
51 | * | |
28979d65 CW |
52 | * @var string|null |
53 | * (SQL type: varchar(64)) | |
54 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
55 | */ |
56 | public $name; | |
c3fc2621 | 57 | |
e501603b TO |
58 | /** |
59 | * 2-4 Character Abbreviation of State/Province | |
60 | * | |
28979d65 CW |
61 | * @var string|null |
62 | * (SQL type: varchar(4)) | |
63 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
64 | */ |
65 | public $abbreviation; | |
c3fc2621 | 66 | |
e501603b TO |
67 | /** |
68 | * ID of Country that State/Province belong | |
69 | * | |
28979d65 CW |
70 | * @var int|string |
71 | * (SQL type: int unsigned) | |
72 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
73 | */ |
74 | public $country_id; | |
c3fc2621 | 75 | |
005f02ec MW |
76 | /** |
77 | * Is this StateProvince active? | |
78 | * | |
c1e814c7 | 79 | * @var bool|string |
28979d65 CW |
80 | * (SQL type: tinyint) |
81 | * Note that values will be retrieved from the database as a string. | |
005f02ec MW |
82 | */ |
83 | public $is_active; | |
84 | ||
e501603b | 85 | /** |
f41f0342 | 86 | * Class constructor. |
e501603b | 87 | */ |
c3fc2621 | 88 | public function __construct() { |
e501603b TO |
89 | $this->__table = 'civicrm_state_province'; |
90 | parent::__construct(); | |
91 | } | |
c3fc2621 | 92 | |
449c4e6b CW |
93 | /** |
94 | * Returns localized title of this entity. | |
7b66c3b5 AH |
95 | * |
96 | * @param bool $plural | |
97 | * Whether to return the plural version of the title. | |
449c4e6b | 98 | */ |
7b66c3b5 | 99 | public static function getEntityTitle($plural = FALSE) { |
5ad66c4f | 100 | return $plural ? ts('States/Provinces') : ts('State/Province'); |
449c4e6b CW |
101 | } |
102 | ||
e501603b | 103 | /** |
f41f0342 | 104 | * Returns foreign keys and entity references. |
e501603b TO |
105 | * |
106 | * @return array | |
107 | * [CRM_Core_Reference_Interface] | |
108 | */ | |
c3fc2621 | 109 | public static function getReferenceColumns() { |
346aaaba | 110 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
fa45b5b9 | 111 | Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); |
c3fc2621 | 112 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'country_id', 'civicrm_country', 'id'); |
346aaaba | 113 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); |
e501603b | 114 | } |
346aaaba | 115 | return Civi::$statics[__CLASS__]['links']; |
e501603b | 116 | } |
c3fc2621 | 117 | |
e501603b TO |
118 | /** |
119 | * Returns all the column names of this table | |
120 | * | |
121 | * @return array | |
122 | */ | |
c3fc2621 | 123 | public static function &fields() { |
346aaaba | 124 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
c3fc2621 CW |
125 | Civi::$statics[__CLASS__]['fields'] = [ |
126 | 'id' => [ | |
e501603b TO |
127 | 'name' => 'id', |
128 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 129 | 'title' => ts('State ID'), |
215b423e | 130 | 'description' => ts('State/Province ID'), |
c3fc2621 | 131 | 'required' => TRUE, |
a36434b9 | 132 | 'where' => 'civicrm_state_province.id', |
522a26c9 | 133 | 'table_name' => 'civicrm_state_province', |
134 | 'entity' => 'StateProvince', | |
135 | 'bao' => 'CRM_Core_DAO_StateProvince', | |
6a7e5e5d | 136 | 'localizable' => 0, |
2cbbebe8 A |
137 | 'html' => [ |
138 | 'type' => 'Number', | |
139 | ], | |
1fe423d6 | 140 | 'readonly' => TRUE, |
a9d0587b | 141 | 'add' => '1.1', |
c3fc2621 CW |
142 | ], |
143 | 'name' => [ | |
e501603b TO |
144 | 'name' => 'name', |
145 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 146 | 'title' => ts('State'), |
215b423e | 147 | 'description' => ts('Name of State/Province'), |
e501603b TO |
148 | 'maxlength' => 64, |
149 | 'size' => CRM_Utils_Type::BIG, | |
c3fc2621 | 150 | 'import' => TRUE, |
e501603b TO |
151 | 'where' => 'civicrm_state_province.name', |
152 | 'headerPattern' => '/state|prov(ince)?/i', | |
153 | 'dataPattern' => '/[A-Z]{2}/', | |
c3fc2621 | 154 | 'export' => TRUE, |
522a26c9 | 155 | 'table_name' => 'civicrm_state_province', |
156 | 'entity' => 'StateProvince', | |
157 | 'bao' => 'CRM_Core_DAO_StateProvince', | |
6a7e5e5d | 158 | 'localizable' => 0, |
a9d0587b | 159 | 'add' => '1.1', |
c3fc2621 CW |
160 | ], |
161 | 'abbreviation' => [ | |
e501603b TO |
162 | 'name' => 'abbreviation', |
163 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 164 | 'title' => ts('State Abbreviation'), |
215b423e | 165 | 'description' => ts('2-4 Character Abbreviation of State/Province'), |
e501603b TO |
166 | 'maxlength' => 4, |
167 | 'size' => CRM_Utils_Type::FOUR, | |
a36434b9 | 168 | 'where' => 'civicrm_state_province.abbreviation', |
522a26c9 | 169 | 'table_name' => 'civicrm_state_province', |
170 | 'entity' => 'StateProvince', | |
171 | 'bao' => 'CRM_Core_DAO_StateProvince', | |
6a7e5e5d | 172 | 'localizable' => 0, |
a9d0587b | 173 | 'add' => '1.1', |
c3fc2621 CW |
174 | ], |
175 | 'country_id' => [ | |
e501603b TO |
176 | 'name' => 'country_id', |
177 | 'type' => CRM_Utils_Type::T_INT, | |
2cbbebe8 | 178 | 'title' => ts('Country ID'), |
215b423e | 179 | 'description' => ts('ID of Country that State/Province belong'), |
c3fc2621 | 180 | 'required' => TRUE, |
a36434b9 | 181 | 'where' => 'civicrm_state_province.country_id', |
522a26c9 | 182 | 'table_name' => 'civicrm_state_province', |
183 | 'entity' => 'StateProvince', | |
184 | 'bao' => 'CRM_Core_DAO_StateProvince', | |
6a7e5e5d | 185 | 'localizable' => 0, |
e501603b | 186 | 'FKClassName' => 'CRM_Core_DAO_Country', |
2cbbebe8 A |
187 | 'html' => [ |
188 | 'label' => ts("Country"), | |
189 | ], | |
a9d0587b | 190 | 'add' => '1.1', |
c3fc2621 | 191 | ], |
005f02ec MW |
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?'), | |
c1e814c7 | 197 | 'required' => TRUE, |
005f02ec MW |
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 | ], | |
c3fc2621 | 206 | ]; |
346aaaba | 207 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 208 | } |
346aaaba | 209 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 210 | } |
c3fc2621 | 211 | |
e501603b | 212 | /** |
bd8e0b14 | 213 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
214 | * |
215 | * @return array | |
bd8e0b14 | 216 | * Array(string $name => string $uniqueName). |
e501603b | 217 | */ |
c3fc2621 | 218 | public static function &fieldKeys() { |
bd8e0b14 TO |
219 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
220 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 221 | } |
bd8e0b14 | 222 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 223 | } |
c3fc2621 | 224 | |
e501603b TO |
225 | /** |
226 | * Returns the names of this table | |
227 | * | |
228 | * @return string | |
229 | */ | |
c3fc2621 | 230 | public static function getTableName() { |
e501603b TO |
231 | return self::$_tableName; |
232 | } | |
c3fc2621 | 233 | |
e501603b TO |
234 | /** |
235 | * Returns if this table needs to be logged | |
236 | * | |
c3fc2621 | 237 | * @return bool |
e501603b | 238 | */ |
c3fc2621 | 239 | public function getLog() { |
e501603b TO |
240 | return self::$_log; |
241 | } | |
c3fc2621 | 242 | |
e501603b TO |
243 | /** |
244 | * Returns the list of fields that can be imported | |
245 | * | |
246 | * @param bool $prefix | |
247 | * | |
248 | * @return array | |
249 | */ | |
c3fc2621 CW |
250 | public static function &import($prefix = FALSE) { |
251 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'state_province', $prefix, []); | |
60808919 | 252 | return $r; |
e501603b | 253 | } |
c3fc2621 | 254 | |
e501603b TO |
255 | /** |
256 | * Returns the list of fields that can be exported | |
257 | * | |
258 | * @param bool $prefix | |
259 | * | |
260 | * @return array | |
261 | */ | |
c3fc2621 CW |
262 | public static function &export($prefix = FALSE) { |
263 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'state_province', $prefix, []); | |
60808919 | 264 | return $r; |
e501603b | 265 | } |
c3fc2621 | 266 | |
e7a6b91a AS |
267 | /** |
268 | * Returns the list of indices | |
c3fc2621 CW |
269 | * |
270 | * @param bool $localize | |
271 | * | |
272 | * @return array | |
e7a6b91a AS |
273 | */ |
274 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
275 | $indices = [ |
276 | 'UI_name_country_id' => [ | |
e7a6b91a | 277 | 'name' => 'UI_name_country_id', |
c3fc2621 | 278 | 'field' => [ |
e7a6b91a AS |
279 | 0 => 'name', |
280 | 1 => 'country_id', | |
c3fc2621 CW |
281 | ], |
282 | 'localizable' => FALSE, | |
283 | 'unique' => TRUE, | |
e7a6b91a | 284 | 'sig' => 'civicrm_state_province::1::name::country_id', |
c3fc2621 CW |
285 | ], |
286 | ]; | |
e7a6b91a AS |
287 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
288 | } | |
c3fc2621 | 289 | |
e501603b | 290 | } |