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:22bfd6264c17c80a3638b9860cb97767)
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 localized title of this entity.
70 public static function getEntityTitle() {
71 return ts('State Provinces');
75 * Returns foreign keys and entity references.
78 * [CRM_Core_Reference_Interface]
80 public static function getReferenceColumns() {
81 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
82 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
83 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'country_id', 'civicrm_country', 'id');
84 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
86 return Civi
::$statics[__CLASS__
]['links'];
90 * Returns all the column names of this table
94 public static function &fields() {
95 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
96 Civi
::$statics[__CLASS__
]['fields'] = [
99 'type' => CRM_Utils_Type
::T_INT
,
100 'title' => ts('State ID'),
101 'description' => ts('State/Province ID'),
103 'where' => 'civicrm_state_province.id',
104 'table_name' => 'civicrm_state_province',
105 'entity' => 'StateProvince',
106 'bao' => 'CRM_Core_DAO_StateProvince',
112 'type' => CRM_Utils_Type
::T_STRING
,
113 'title' => ts('State'),
114 'description' => ts('Name of State/Province'),
116 'size' => CRM_Utils_Type
::BIG
,
118 'where' => 'civicrm_state_province.name',
119 'headerPattern' => '/state|prov(ince)?/i',
120 'dataPattern' => '/[A-Z]{2}/',
122 'table_name' => 'civicrm_state_province',
123 'entity' => 'StateProvince',
124 'bao' => 'CRM_Core_DAO_StateProvince',
129 'name' => 'abbreviation',
130 'type' => CRM_Utils_Type
::T_STRING
,
131 'title' => ts('State Abbreviation'),
132 'description' => ts('2-4 Character Abbreviation of State/Province'),
134 'size' => CRM_Utils_Type
::FOUR
,
135 'where' => 'civicrm_state_province.abbreviation',
136 'table_name' => 'civicrm_state_province',
137 'entity' => 'StateProvince',
138 'bao' => 'CRM_Core_DAO_StateProvince',
143 'name' => 'country_id',
144 'type' => CRM_Utils_Type
::T_INT
,
145 'title' => ts('Country'),
146 'description' => ts('ID of Country that State/Province belong'),
148 'where' => 'civicrm_state_province.country_id',
149 'table_name' => 'civicrm_state_province',
150 'entity' => 'StateProvince',
151 'bao' => 'CRM_Core_DAO_StateProvince',
153 'FKClassName' => 'CRM_Core_DAO_Country',
157 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
159 return Civi
::$statics[__CLASS__
]['fields'];
163 * Return a mapping from field-name to the corresponding key (as used in fields()).
166 * Array(string $name => string $uniqueName).
168 public static function &fieldKeys() {
169 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
170 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
172 return Civi
::$statics[__CLASS__
]['fieldKeys'];
176 * Returns the names of this table
180 public static function getTableName() {
181 return self
::$_tableName;
185 * Returns if this table needs to be logged
189 public function getLog() {
194 * Returns the list of fields that can be imported
196 * @param bool $prefix
200 public static function &import($prefix = FALSE) {
201 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'state_province', $prefix, []);
206 * Returns the list of fields that can be exported
208 * @param bool $prefix
212 public static function &export($prefix = FALSE) {
213 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'state_province', $prefix, []);
218 * Returns the list of indices
220 * @param bool $localize
224 public static function indices($localize = TRUE) {
226 'UI_name_country_id' => [
227 'name' => 'UI_name_country_id',
232 'localizable' => FALSE,
234 'sig' => 'civicrm_state_province::1::name::country_id',
237 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;