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:ca396996ffd11fc0b89e34657679a9ad)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = FALSE;
41 * Name of State/Province
48 * 2-4 Character Abbreviation of State/Province
55 * ID of Country that State/Province belong
64 public function __construct() {
65 $this->__table
= 'civicrm_state_province';
66 parent
::__construct();
70 * Returns localized title of this entity.
73 * Whether to return the plural version of the title.
75 public static function getEntityTitle($plural = FALSE) {
76 return $plural ?
ts('State Provinces') : ts('State Province');
80 * Returns foreign keys and entity references.
83 * [CRM_Core_Reference_Interface]
85 public static function getReferenceColumns() {
86 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
87 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
88 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'country_id', 'civicrm_country', 'id');
89 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
91 return Civi
::$statics[__CLASS__
]['links'];
95 * Returns all the column names of this table
99 public static function &fields() {
100 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
101 Civi
::$statics[__CLASS__
]['fields'] = [
104 'type' => CRM_Utils_Type
::T_INT
,
105 'title' => ts('State ID'),
106 'description' => ts('State/Province ID'),
108 'where' => 'civicrm_state_province.id',
109 'table_name' => 'civicrm_state_province',
110 'entity' => 'StateProvince',
111 'bao' => 'CRM_Core_DAO_StateProvince',
117 'type' => CRM_Utils_Type
::T_STRING
,
118 'title' => ts('State'),
119 'description' => ts('Name of State/Province'),
121 'size' => CRM_Utils_Type
::BIG
,
123 'where' => 'civicrm_state_province.name',
124 'headerPattern' => '/state|prov(ince)?/i',
125 'dataPattern' => '/[A-Z]{2}/',
127 'table_name' => 'civicrm_state_province',
128 'entity' => 'StateProvince',
129 'bao' => 'CRM_Core_DAO_StateProvince',
134 'name' => 'abbreviation',
135 'type' => CRM_Utils_Type
::T_STRING
,
136 'title' => ts('State Abbreviation'),
137 'description' => ts('2-4 Character Abbreviation of State/Province'),
139 'size' => CRM_Utils_Type
::FOUR
,
140 'where' => 'civicrm_state_province.abbreviation',
141 'table_name' => 'civicrm_state_province',
142 'entity' => 'StateProvince',
143 'bao' => 'CRM_Core_DAO_StateProvince',
148 'name' => 'country_id',
149 'type' => CRM_Utils_Type
::T_INT
,
150 'title' => ts('Country'),
151 'description' => ts('ID of Country that State/Province belong'),
153 'where' => 'civicrm_state_province.country_id',
154 'table_name' => 'civicrm_state_province',
155 'entity' => 'StateProvince',
156 'bao' => 'CRM_Core_DAO_StateProvince',
158 'FKClassName' => 'CRM_Core_DAO_Country',
162 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
164 return Civi
::$statics[__CLASS__
]['fields'];
168 * Return a mapping from field-name to the corresponding key (as used in fields()).
171 * Array(string $name => string $uniqueName).
173 public static function &fieldKeys() {
174 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
175 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
177 return Civi
::$statics[__CLASS__
]['fieldKeys'];
181 * Returns the names of this table
185 public static function getTableName() {
186 return self
::$_tableName;
190 * Returns if this table needs to be logged
194 public function getLog() {
199 * Returns the list of fields that can be imported
201 * @param bool $prefix
205 public static function &import($prefix = FALSE) {
206 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'state_province', $prefix, []);
211 * Returns the list of fields that can be exported
213 * @param bool $prefix
217 public static function &export($prefix = FALSE) {
218 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'state_province', $prefix, []);
223 * Returns the list of indices
225 * @param bool $localize
229 public static function indices($localize = TRUE) {
231 'UI_name_country_id' => [
232 'name' => 'UI_name_country_id',
237 'localizable' => FALSE,
239 'sig' => 'civicrm_state_province::1::name::country_id',
242 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;