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