Merge pull request #17067 from colemanw/importSubmit
[civicrm-core.git] / CRM / Core / DAO / County.php
CommitLineData
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
96012881 9 * (GenCodeChecksum:c22121afe6539d3ec7c51e905de299d7)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the County entity.
f41f0342 14 */
e501603b 15class CRM_Core_DAO_County 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_county';
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 * County ID
33 *
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * Name of County
40 *
41 * @var string
42 */
43 public $name;
c3fc2621 44
e501603b
TO
45 /**
46 * 2-4 Character Abbreviation of County
47 *
48 * @var string
49 */
50 public $abbreviation;
c3fc2621 51
e501603b
TO
52 /**
53 * ID of State/Province that County belongs
54 *
e6ca0a57 55 * @var int
e501603b
TO
56 */
57 public $state_province_id;
c3fc2621 58
e501603b 59 /**
f41f0342 60 * Class constructor.
e501603b 61 */
c3fc2621 62 public function __construct() {
e501603b
TO
63 $this->__table = 'civicrm_county';
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(), 'state_province_id', 'civicrm_state_province', '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('County ID'),
215b423e 94 'description' => ts('County ID'),
c3fc2621 95 'required' => TRUE,
a36434b9 96 'where' => 'civicrm_county.id',
522a26c9 97 'table_name' => 'civicrm_county',
98 'entity' => 'County',
99 'bao' => 'CRM_Core_DAO_County',
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('County'),
215b423e 106 'description' => ts('Name of County'),
e501603b
TO
107 'maxlength' => 64,
108 'size' => CRM_Utils_Type::BIG,
c3fc2621 109 'import' => TRUE,
e501603b
TO
110 'where' => 'civicrm_county.name',
111 'headerPattern' => '/county/i',
112 'dataPattern' => '/[A-Z]{2}/',
c3fc2621 113 'export' => TRUE,
522a26c9 114 'table_name' => 'civicrm_county',
115 'entity' => 'County',
116 'bao' => 'CRM_Core_DAO_County',
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('County Abbreviation'),
215b423e 123 'description' => ts('2-4 Character Abbreviation of County'),
e501603b
TO
124 'maxlength' => 4,
125 'size' => CRM_Utils_Type::FOUR,
a36434b9 126 'where' => 'civicrm_county.abbreviation',
522a26c9 127 'table_name' => 'civicrm_county',
128 'entity' => 'County',
129 'bao' => 'CRM_Core_DAO_County',
6a7e5e5d 130 'localizable' => 0,
c3fc2621
CW
131 ],
132 'state_province_id' => [
e501603b
TO
133 'name' => 'state_province_id',
134 'type' => CRM_Utils_Type::T_INT,
c3fc2621 135 'title' => ts('State'),
215b423e 136 'description' => ts('ID of State/Province that County belongs'),
c3fc2621 137 'required' => TRUE,
a36434b9 138 'where' => 'civicrm_county.state_province_id',
522a26c9 139 'table_name' => 'civicrm_county',
140 'entity' => 'County',
141 'bao' => 'CRM_Core_DAO_County',
6a7e5e5d 142 'localizable' => 0,
e501603b 143 'FKClassName' => 'CRM_Core_DAO_StateProvince',
96012881
PN
144 'pseudoconstant' => [
145 'table' => 'civicrm_state_province',
146 'keyColumn' => 'id',
147 'labelColumn' => 'name',
148 ],
c3fc2621
CW
149 ],
150 ];
346aaaba 151 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 152 }
346aaaba 153 return Civi::$statics[__CLASS__]['fields'];
e501603b 154 }
c3fc2621 155
e501603b 156 /**
bd8e0b14 157 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
158 *
159 * @return array
bd8e0b14 160 * Array(string $name => string $uniqueName).
e501603b 161 */
c3fc2621 162 public static function &fieldKeys() {
bd8e0b14
TO
163 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
164 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 165 }
bd8e0b14 166 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 167 }
c3fc2621 168
e501603b
TO
169 /**
170 * Returns the names of this table
171 *
172 * @return string
173 */
c3fc2621 174 public static function getTableName() {
e501603b
TO
175 return self::$_tableName;
176 }
c3fc2621 177
e501603b
TO
178 /**
179 * Returns if this table needs to be logged
180 *
c3fc2621 181 * @return bool
e501603b 182 */
c3fc2621 183 public function getLog() {
e501603b
TO
184 return self::$_log;
185 }
c3fc2621 186
e501603b
TO
187 /**
188 * Returns the list of fields that can be imported
189 *
190 * @param bool $prefix
191 *
192 * @return array
193 */
c3fc2621
CW
194 public static function &import($prefix = FALSE) {
195 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'county', $prefix, []);
60808919 196 return $r;
e501603b 197 }
c3fc2621 198
e501603b
TO
199 /**
200 * Returns the list of fields that can be exported
201 *
202 * @param bool $prefix
203 *
204 * @return array
205 */
c3fc2621
CW
206 public static function &export($prefix = FALSE) {
207 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'county', $prefix, []);
60808919 208 return $r;
e501603b 209 }
c3fc2621 210
e7a6b91a
AS
211 /**
212 * Returns the list of indices
c3fc2621
CW
213 *
214 * @param bool $localize
215 *
216 * @return array
e7a6b91a
AS
217 */
218 public static function indices($localize = TRUE) {
c3fc2621
CW
219 $indices = [
220 'UI_name_state_id' => [
e7a6b91a 221 'name' => 'UI_name_state_id',
c3fc2621 222 'field' => [
e7a6b91a
AS
223 0 => 'name',
224 1 => 'state_province_id',
c3fc2621
CW
225 ],
226 'localizable' => FALSE,
227 'unique' => TRUE,
e7a6b91a 228 'sig' => 'civicrm_county::1::name::state_province_id',
c3fc2621
CW
229 ],
230 ];
e7a6b91a
AS
231 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
232 }
c3fc2621 233
e501603b 234}