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