5 * @copyright CiviCRM LLC (c) 2004-2018
7 * Generated from xml/schema/CRM/Core/StateProvince.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:7688143f6e0d809b020a3153f60aff7e)
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 static $_tableName = 'civicrm_state_province';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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 'table_name' => 'civicrm_state_province',
97 'entity' => 'StateProvince',
98 'bao' => 'CRM_Core_DAO_StateProvince',
103 'type' => CRM_Utils_Type
::T_STRING
,
104 'title' => ts('State'),
105 'description' => ts('Name of State/Province'),
107 'size' => CRM_Utils_Type
::BIG
,
109 'where' => 'civicrm_state_province.name',
110 'headerPattern' => '/state|prov(ince)?/i',
111 'dataPattern' => '/[A-Z]{2}/',
113 'table_name' => 'civicrm_state_province',
114 'entity' => 'StateProvince',
115 'bao' => 'CRM_Core_DAO_StateProvince',
119 'name' => 'abbreviation',
120 'type' => CRM_Utils_Type
::T_STRING
,
121 'title' => ts('State Abbreviation'),
122 'description' => ts('2-4 Character Abbreviation of State/Province'),
124 'size' => CRM_Utils_Type
::FOUR
,
125 'table_name' => 'civicrm_state_province',
126 'entity' => 'StateProvince',
127 'bao' => 'CRM_Core_DAO_StateProvince',
131 'name' => 'country_id',
132 'type' => CRM_Utils_Type
::T_INT
,
133 'title' => ts('Country'),
134 'description' => ts('ID of Country that State/Province belong'),
136 'table_name' => 'civicrm_state_province',
137 'entity' => 'StateProvince',
138 'bao' => 'CRM_Core_DAO_StateProvince',
140 'FKClassName' => 'CRM_Core_DAO_Country',
143 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
145 return Civi
::$statics[__CLASS__
]['fields'];
149 * Return a mapping from field-name to the corresponding key (as used in fields()).
152 * Array(string $name => string $uniqueName).
154 public static function &fieldKeys() {
155 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
156 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
158 return Civi
::$statics[__CLASS__
]['fieldKeys'];
162 * Returns the names of this table
166 public static function getTableName() {
167 return self
::$_tableName;
171 * Returns if this table needs to be logged
175 public function getLog() {
180 * Returns the list of fields that can be imported
182 * @param bool $prefix
186 public static function &import($prefix = FALSE) {
187 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'state_province', $prefix, []);
192 * Returns the list of fields that can be exported
194 * @param bool $prefix
198 public static function &export($prefix = FALSE) {
199 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'state_province', $prefix, []);
204 * Returns the list of indices
206 * @param bool $localize
210 public static function indices($localize = TRUE) {
212 'UI_name_country_id' => [
213 'name' => 'UI_name_country_id',
218 'localizable' => FALSE,
220 'sig' => 'civicrm_state_province::1::name::country_id',
223 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;