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/County.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
70c5cd97 | 9 | * (GenCodeChecksum:f54f7ff28a6ecde09252698c389db154) |
e501603b | 10 | */ |
c3fc2621 | 11 | |
f41f0342 | 12 | /** |
c3fc2621 | 13 | * Database access object for the County entity. |
f41f0342 | 14 | */ |
e501603b | 15 | class CRM_Core_DAO_County 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_county'; |
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 | * County ID | |
42 | * | |
e6ca0a57 | 43 | * @var int |
e501603b TO |
44 | */ |
45 | public $id; | |
c3fc2621 | 46 | |
e501603b TO |
47 | /** |
48 | * Name of County | |
49 | * | |
50 | * @var string | |
51 | */ | |
52 | public $name; | |
c3fc2621 | 53 | |
e501603b TO |
54 | /** |
55 | * 2-4 Character Abbreviation of County | |
56 | * | |
57 | * @var string | |
58 | */ | |
59 | public $abbreviation; | |
c3fc2621 | 60 | |
e501603b TO |
61 | /** |
62 | * ID of State/Province that County belongs | |
63 | * | |
e6ca0a57 | 64 | * @var int |
e501603b TO |
65 | */ |
66 | public $state_province_id; | |
c3fc2621 | 67 | |
005f02ec MW |
68 | /** |
69 | * Is this County 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_county'; |
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 AH |
89 | public static function getEntityTitle($plural = FALSE) { |
90 | return $plural ? ts('Counties') : ts('County'); | |
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(), 'state_province_id', 'civicrm_state_province', '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('County ID'), |
215b423e | 120 | 'description' => ts('County ID'), |
c3fc2621 | 121 | 'required' => TRUE, |
a36434b9 | 122 | 'where' => 'civicrm_county.id', |
522a26c9 | 123 | 'table_name' => 'civicrm_county', |
124 | 'entity' => 'County', | |
125 | 'bao' => 'CRM_Core_DAO_County', | |
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('County'), |
215b423e | 137 | 'description' => ts('Name of County'), |
e501603b TO |
138 | 'maxlength' => 64, |
139 | 'size' => CRM_Utils_Type::BIG, | |
c3fc2621 | 140 | 'import' => TRUE, |
e501603b TO |
141 | 'where' => 'civicrm_county.name', |
142 | 'headerPattern' => '/county/i', | |
143 | 'dataPattern' => '/[A-Z]{2}/', | |
c3fc2621 | 144 | 'export' => TRUE, |
522a26c9 | 145 | 'table_name' => 'civicrm_county', |
146 | 'entity' => 'County', | |
147 | 'bao' => 'CRM_Core_DAO_County', | |
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('County Abbreviation'), |
215b423e | 155 | 'description' => ts('2-4 Character Abbreviation of County'), |
e501603b TO |
156 | 'maxlength' => 4, |
157 | 'size' => CRM_Utils_Type::FOUR, | |
a36434b9 | 158 | 'where' => 'civicrm_county.abbreviation', |
522a26c9 | 159 | 'table_name' => 'civicrm_county', |
160 | 'entity' => 'County', | |
161 | 'bao' => 'CRM_Core_DAO_County', | |
6a7e5e5d | 162 | 'localizable' => 0, |
a9d0587b | 163 | 'add' => '1.1', |
c3fc2621 CW |
164 | ], |
165 | 'state_province_id' => [ | |
e501603b TO |
166 | 'name' => 'state_province_id', |
167 | 'type' => CRM_Utils_Type::T_INT, | |
2cbbebe8 | 168 | 'title' => ts('State ID'), |
215b423e | 169 | 'description' => ts('ID of State/Province that County belongs'), |
c3fc2621 | 170 | 'required' => TRUE, |
a36434b9 | 171 | 'where' => 'civicrm_county.state_province_id', |
522a26c9 | 172 | 'table_name' => 'civicrm_county', |
173 | 'entity' => 'County', | |
174 | 'bao' => 'CRM_Core_DAO_County', | |
6a7e5e5d | 175 | 'localizable' => 0, |
e501603b | 176 | 'FKClassName' => 'CRM_Core_DAO_StateProvince', |
2cbbebe8 A |
177 | 'html' => [ |
178 | 'label' => ts("State"), | |
179 | ], | |
96012881 PN |
180 | 'pseudoconstant' => [ |
181 | 'table' => 'civicrm_state_province', | |
182 | 'keyColumn' => 'id', | |
183 | 'labelColumn' => 'name', | |
70c5cd97 | 184 | 'abbrColumn' => 'abbreviation', |
96012881 | 185 | ], |
a9d0587b | 186 | 'add' => '1.1', |
c3fc2621 | 187 | ], |
005f02ec MW |
188 | 'is_active' => [ |
189 | 'name' => 'is_active', | |
190 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
191 | 'title' => ts('County Is Active'), | |
192 | 'description' => ts('Is this County active?'), | |
193 | 'where' => 'civicrm_county.is_active', | |
194 | 'default' => '1', | |
195 | 'table_name' => 'civicrm_county', | |
196 | 'entity' => 'County', | |
197 | 'bao' => 'CRM_Core_DAO_County', | |
198 | 'localizable' => 0, | |
199 | 'add' => '5.35', | |
200 | ], | |
c3fc2621 | 201 | ]; |
346aaaba | 202 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 203 | } |
346aaaba | 204 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 205 | } |
c3fc2621 | 206 | |
e501603b | 207 | /** |
bd8e0b14 | 208 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
209 | * |
210 | * @return array | |
bd8e0b14 | 211 | * Array(string $name => string $uniqueName). |
e501603b | 212 | */ |
c3fc2621 | 213 | public static function &fieldKeys() { |
bd8e0b14 TO |
214 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
215 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 216 | } |
bd8e0b14 | 217 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 218 | } |
c3fc2621 | 219 | |
e501603b TO |
220 | /** |
221 | * Returns the names of this table | |
222 | * | |
223 | * @return string | |
224 | */ | |
c3fc2621 | 225 | public static function getTableName() { |
e501603b TO |
226 | return self::$_tableName; |
227 | } | |
c3fc2621 | 228 | |
e501603b TO |
229 | /** |
230 | * Returns if this table needs to be logged | |
231 | * | |
c3fc2621 | 232 | * @return bool |
e501603b | 233 | */ |
c3fc2621 | 234 | public function getLog() { |
e501603b TO |
235 | return self::$_log; |
236 | } | |
c3fc2621 | 237 | |
e501603b TO |
238 | /** |
239 | * Returns the list of fields that can be imported | |
240 | * | |
241 | * @param bool $prefix | |
242 | * | |
243 | * @return array | |
244 | */ | |
c3fc2621 CW |
245 | public static function &import($prefix = FALSE) { |
246 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'county', $prefix, []); | |
60808919 | 247 | return $r; |
e501603b | 248 | } |
c3fc2621 | 249 | |
e501603b TO |
250 | /** |
251 | * Returns the list of fields that can be exported | |
252 | * | |
253 | * @param bool $prefix | |
254 | * | |
255 | * @return array | |
256 | */ | |
c3fc2621 CW |
257 | public static function &export($prefix = FALSE) { |
258 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'county', $prefix, []); | |
60808919 | 259 | return $r; |
e501603b | 260 | } |
c3fc2621 | 261 | |
e7a6b91a AS |
262 | /** |
263 | * Returns the list of indices | |
c3fc2621 CW |
264 | * |
265 | * @param bool $localize | |
266 | * | |
267 | * @return array | |
e7a6b91a AS |
268 | */ |
269 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
270 | $indices = [ |
271 | 'UI_name_state_id' => [ | |
e7a6b91a | 272 | 'name' => 'UI_name_state_id', |
c3fc2621 | 273 | 'field' => [ |
e7a6b91a AS |
274 | 0 => 'name', |
275 | 1 => 'state_province_id', | |
c3fc2621 CW |
276 | ], |
277 | 'localizable' => FALSE, | |
278 | 'unique' => TRUE, | |
e7a6b91a | 279 | 'sig' => 'civicrm_county::1::name::state_province_id', |
c3fc2621 CW |
280 | ], |
281 | ]; | |
e7a6b91a AS |
282 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
283 | } | |
c3fc2621 | 284 | |
e501603b | 285 | } |