5 * @copyright CiviCRM LLC (c) 2004-2019
7 * Generated from xml/schema/CRM/Core/StateProvince.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:38620d39135bc4e42f0cc688dff9cb5b)
13 * Database access object for the StateProvince entity.
15 class CRM_Core_DAO_StateProvince
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_state_province';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = FALSE;
39 * Name of State/Province
46 * 2-4 Character Abbreviation of State/Province
53 * ID of Country that State/Province belong
62 public function __construct() {
63 $this->__table
= 'civicrm_state_province';
64 parent
::__construct();
68 * Returns foreign keys and entity references.
71 * [CRM_Core_Reference_Interface]
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(), 'country_id', 'civicrm_country', 'id');
77 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
79 return Civi
::$statics[__CLASS__
]['links'];
83 * Returns all the column names of this table
87 public static function &fields() {
88 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
89 Civi
::$statics[__CLASS__
]['fields'] = [
92 'type' => CRM_Utils_Type
::T_INT
,
93 'title' => ts('State ID'),
94 'description' => ts('State/Province ID'),
96 'where' => 'civicrm_state_province.id',
97 'table_name' => 'civicrm_state_province',
98 'entity' => 'StateProvince',
99 'bao' => 'CRM_Core_DAO_StateProvince',
104 'type' => CRM_Utils_Type
::T_STRING
,
105 'title' => ts('State'),
106 'description' => ts('Name of State/Province'),
108 'size' => CRM_Utils_Type
::BIG
,
110 'where' => 'civicrm_state_province.name',
111 'headerPattern' => '/state|prov(ince)?/i',
112 'dataPattern' => '/[A-Z]{2}/',
114 'table_name' => 'civicrm_state_province',
115 'entity' => 'StateProvince',
116 'bao' => 'CRM_Core_DAO_StateProvince',
120 'name' => 'abbreviation',
121 'type' => CRM_Utils_Type
::T_STRING
,
122 'title' => ts('State Abbreviation'),
123 'description' => ts('2-4 Character Abbreviation of State/Province'),
125 'size' => CRM_Utils_Type
::FOUR
,
126 'where' => 'civicrm_state_province.abbreviation',
127 'table_name' => 'civicrm_state_province',
128 'entity' => 'StateProvince',
129 'bao' => 'CRM_Core_DAO_StateProvince',
133 'name' => 'country_id',
134 'type' => CRM_Utils_Type
::T_INT
,
135 'title' => ts('Country'),
136 'description' => ts('ID of Country that State/Province belong'),
138 'where' => 'civicrm_state_province.country_id',
139 'table_name' => 'civicrm_state_province',
140 'entity' => 'StateProvince',
141 'bao' => 'CRM_Core_DAO_StateProvince',
143 'FKClassName' => 'CRM_Core_DAO_Country',
146 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
148 return Civi
::$statics[__CLASS__
]['fields'];
152 * Return a mapping from field-name to the corresponding key (as used in fields()).
155 * Array(string $name => string $uniqueName).
157 public static function &fieldKeys() {
158 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
159 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
161 return Civi
::$statics[__CLASS__
]['fieldKeys'];
165 * Returns the names of this table
169 public static function getTableName() {
170 return self
::$_tableName;
174 * Returns if this table needs to be logged
178 public function getLog() {
183 * Returns the list of fields that can be imported
185 * @param bool $prefix
189 public static function &import($prefix = FALSE) {
190 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'state_province', $prefix, []);
195 * Returns the list of fields that can be exported
197 * @param bool $prefix
201 public static function &export($prefix = FALSE) {
202 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'state_province', $prefix, []);
207 * Returns the list of indices
209 * @param bool $localize
213 public static function indices($localize = TRUE) {
215 'UI_name_country_id' => [
216 'name' => 'UI_name_country_id',
221 'localizable' => FALSE,
223 'sig' => 'civicrm_state_province::1::name::country_id',
226 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;