Merge pull request #13337 from GinkgoFJG/crmPageTitle
[civicrm-core.git] / CRM / Core / DAO / StateProvince.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
6b83d5bd 5 * @copyright CiviCRM LLC (c) 2004-2019
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Core/StateProvince.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
e380ee3b 9 * (GenCodeChecksum:66bbfa3f81cb6baec8d7175f5f32718a)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the StateProvince entity.
f41f0342 14 */
e501603b 15class 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 */
22 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 */
c3fc2621
CW
29 static $_log = FALSE;
30
e501603b
TO
31 /**
32 * State/Province ID
33 *
34 * @var int unsigned
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 *
55 * @var int unsigned
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
TO
74 if (!isset(Civi::$statics[__CLASS__]['links'])) {
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,
522a26c9 96 'table_name' => 'civicrm_state_province',
97 'entity' => 'StateProvince',
98 'bao' => 'CRM_Core_DAO_StateProvince',
6a7e5e5d 99 'localizable' => 0,
c3fc2621
CW
100 ],
101 'name' => [
e501603b
TO
102 'name' => 'name',
103 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 104 'title' => ts('State'),
215b423e 105 'description' => ts('Name of State/Province'),
e501603b
TO
106 'maxlength' => 64,
107 'size' => CRM_Utils_Type::BIG,
c3fc2621 108 'import' => TRUE,
e501603b
TO
109 'where' => 'civicrm_state_province.name',
110 'headerPattern' => '/state|prov(ince)?/i',
111 'dataPattern' => '/[A-Z]{2}/',
c3fc2621 112 'export' => TRUE,
522a26c9 113 'table_name' => 'civicrm_state_province',
114 'entity' => 'StateProvince',
115 'bao' => 'CRM_Core_DAO_StateProvince',
6a7e5e5d 116 'localizable' => 0,
c3fc2621
CW
117 ],
118 'abbreviation' => [
e501603b
TO
119 'name' => 'abbreviation',
120 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 121 'title' => ts('State Abbreviation'),
215b423e 122 'description' => ts('2-4 Character Abbreviation of State/Province'),
e501603b
TO
123 'maxlength' => 4,
124 'size' => CRM_Utils_Type::FOUR,
522a26c9 125 'table_name' => 'civicrm_state_province',
126 'entity' => 'StateProvince',
127 'bao' => 'CRM_Core_DAO_StateProvince',
6a7e5e5d 128 'localizable' => 0,
c3fc2621
CW
129 ],
130 'country_id' => [
e501603b
TO
131 'name' => 'country_id',
132 'type' => CRM_Utils_Type::T_INT,
c3fc2621 133 'title' => ts('Country'),
215b423e 134 'description' => ts('ID of Country that State/Province belong'),
c3fc2621 135 'required' => TRUE,
522a26c9 136 'table_name' => 'civicrm_state_province',
137 'entity' => 'StateProvince',
138 'bao' => 'CRM_Core_DAO_StateProvince',
6a7e5e5d 139 'localizable' => 0,
e501603b 140 'FKClassName' => 'CRM_Core_DAO_Country',
c3fc2621
CW
141 ],
142 ];
346aaaba 143 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 144 }
346aaaba 145 return Civi::$statics[__CLASS__]['fields'];
e501603b 146 }
c3fc2621 147
e501603b 148 /**
bd8e0b14 149 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
150 *
151 * @return array
bd8e0b14 152 * Array(string $name => string $uniqueName).
e501603b 153 */
c3fc2621 154 public static function &fieldKeys() {
bd8e0b14
TO
155 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
156 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 157 }
bd8e0b14 158 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 159 }
c3fc2621 160
e501603b
TO
161 /**
162 * Returns the names of this table
163 *
164 * @return string
165 */
c3fc2621 166 public static function getTableName() {
e501603b
TO
167 return self::$_tableName;
168 }
c3fc2621 169
e501603b
TO
170 /**
171 * Returns if this table needs to be logged
172 *
c3fc2621 173 * @return bool
e501603b 174 */
c3fc2621 175 public function getLog() {
e501603b
TO
176 return self::$_log;
177 }
c3fc2621 178
e501603b
TO
179 /**
180 * Returns the list of fields that can be imported
181 *
182 * @param bool $prefix
183 *
184 * @return array
185 */
c3fc2621
CW
186 public static function &import($prefix = FALSE) {
187 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'state_province', $prefix, []);
60808919 188 return $r;
e501603b 189 }
c3fc2621 190
e501603b
TO
191 /**
192 * Returns the list of fields that can be exported
193 *
194 * @param bool $prefix
195 *
196 * @return array
197 */
c3fc2621
CW
198 public static function &export($prefix = FALSE) {
199 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'state_province', $prefix, []);
60808919 200 return $r;
e501603b 201 }
c3fc2621 202
e7a6b91a
AS
203 /**
204 * Returns the list of indices
c3fc2621
CW
205 *
206 * @param bool $localize
207 *
208 * @return array
e7a6b91a
AS
209 */
210 public static function indices($localize = TRUE) {
c3fc2621
CW
211 $indices = [
212 'UI_name_country_id' => [
e7a6b91a 213 'name' => 'UI_name_country_id',
c3fc2621 214 'field' => [
e7a6b91a
AS
215 0 => 'name',
216 1 => 'country_id',
c3fc2621
CW
217 ],
218 'localizable' => FALSE,
219 'unique' => TRUE,
e7a6b91a 220 'sig' => 'civicrm_state_province::1::name::country_id',
c3fc2621
CW
221 ],
222 ];
e7a6b91a
AS
223 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
224 }
c3fc2621 225
e501603b 226}