5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/StateProvince.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:3807f834dde7f3a4bca379cf6e9d9130)
13 * Database access object for the StateProvince entity.
15 class CRM_Core_DAO_StateProvince
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_state_province';
27 * Field to show when displaying a record.
31 public static $_labelField = 'name';
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = FALSE;
48 * Name of State/Province
55 * 2-4 Character Abbreviation of State/Province
62 * ID of Country that State/Province belong
69 * Is this StateProvince active?
78 public function __construct() {
79 $this->__table
= 'civicrm_state_province';
80 parent
::__construct();
84 * Returns localized title of this entity.
87 * Whether to return the plural version of the title.
89 public static function getEntityTitle($plural = FALSE) {
90 return $plural ?
ts('States/Provinces') : ts('State/Province');
94 * Returns foreign keys and entity references.
97 * [CRM_Core_Reference_Interface]
99 public static function getReferenceColumns() {
100 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
101 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
102 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'country_id', 'civicrm_country', 'id');
103 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
105 return Civi
::$statics[__CLASS__
]['links'];
109 * Returns all the column names of this table
113 public static function &fields() {
114 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
115 Civi
::$statics[__CLASS__
]['fields'] = [
118 'type' => CRM_Utils_Type
::T_INT
,
119 'title' => ts('State ID'),
120 'description' => ts('State/Province ID'),
122 'where' => 'civicrm_state_province.id',
123 'table_name' => 'civicrm_state_province',
124 'entity' => 'StateProvince',
125 'bao' => 'CRM_Core_DAO_StateProvince',
135 'type' => CRM_Utils_Type
::T_STRING
,
136 'title' => ts('State'),
137 'description' => ts('Name of State/Province'),
139 'size' => CRM_Utils_Type
::BIG
,
141 'where' => 'civicrm_state_province.name',
142 'headerPattern' => '/state|prov(ince)?/i',
143 'dataPattern' => '/[A-Z]{2}/',
145 'table_name' => 'civicrm_state_province',
146 'entity' => 'StateProvince',
147 'bao' => 'CRM_Core_DAO_StateProvince',
152 'name' => 'abbreviation',
153 'type' => CRM_Utils_Type
::T_STRING
,
154 'title' => ts('State Abbreviation'),
155 'description' => ts('2-4 Character Abbreviation of State/Province'),
157 'size' => CRM_Utils_Type
::FOUR
,
158 'where' => 'civicrm_state_province.abbreviation',
159 'table_name' => 'civicrm_state_province',
160 'entity' => 'StateProvince',
161 'bao' => 'CRM_Core_DAO_StateProvince',
166 'name' => 'country_id',
167 'type' => CRM_Utils_Type
::T_INT
,
168 'title' => ts('Country ID'),
169 'description' => ts('ID of Country that State/Province belong'),
171 'where' => 'civicrm_state_province.country_id',
172 'table_name' => 'civicrm_state_province',
173 'entity' => 'StateProvince',
174 'bao' => 'CRM_Core_DAO_StateProvince',
176 'FKClassName' => 'CRM_Core_DAO_Country',
178 'label' => ts("Country"),
183 'name' => 'is_active',
184 'type' => CRM_Utils_Type
::T_BOOLEAN
,
185 'title' => ts('StateProvince Is Active'),
186 'description' => ts('Is this StateProvince active?'),
187 'where' => 'civicrm_state_province.is_active',
189 'table_name' => 'civicrm_state_province',
190 'entity' => 'StateProvince',
191 'bao' => 'CRM_Core_DAO_StateProvince',
196 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
198 return Civi
::$statics[__CLASS__
]['fields'];
202 * Return a mapping from field-name to the corresponding key (as used in fields()).
205 * Array(string $name => string $uniqueName).
207 public static function &fieldKeys() {
208 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
209 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
211 return Civi
::$statics[__CLASS__
]['fieldKeys'];
215 * Returns the names of this table
219 public static function getTableName() {
220 return self
::$_tableName;
224 * Returns if this table needs to be logged
228 public function getLog() {
233 * Returns the list of fields that can be imported
235 * @param bool $prefix
239 public static function &import($prefix = FALSE) {
240 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'state_province', $prefix, []);
245 * Returns the list of fields that can be exported
247 * @param bool $prefix
251 public static function &export($prefix = FALSE) {
252 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'state_province', $prefix, []);
257 * Returns the list of indices
259 * @param bool $localize
263 public static function indices($localize = TRUE) {
265 'UI_name_country_id' => [
266 'name' => 'UI_name_country_id',
271 'localizable' => FALSE,
273 'sig' => 'civicrm_state_province::1::name::country_id',
276 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;