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:b52f997bf6a08f0408c349a0ef187779)
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;
43 * @var int|string|null
44 * (SQL type: int unsigned)
45 * Note that values will be retrieved from the database as a string.
50 * Name of State/Province
53 * (SQL type: varchar(64))
54 * Note that values will be retrieved from the database as a string.
59 * 2-4 Character Abbreviation of State/Province
62 * (SQL type: varchar(4))
63 * Note that values will be retrieved from the database as a string.
68 * ID of Country that State/Province belong
71 * (SQL type: int unsigned)
72 * Note that values will be retrieved from the database as a string.
77 * Is this StateProvince active?
81 * Note that values will be retrieved from the database as a string.
88 public function __construct() {
89 $this->__table
= 'civicrm_state_province';
90 parent
::__construct();
94 * Returns localized title of this entity.
97 * Whether to return the plural version of the title.
99 public static function getEntityTitle($plural = FALSE) {
100 return $plural ?
ts('States/Provinces') : ts('State/Province');
104 * Returns foreign keys and entity references.
107 * [CRM_Core_Reference_Interface]
109 public static function getReferenceColumns() {
110 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
111 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
112 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'country_id', 'civicrm_country', 'id');
113 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
115 return Civi
::$statics[__CLASS__
]['links'];
119 * Returns all the column names of this table
123 public static function &fields() {
124 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
125 Civi
::$statics[__CLASS__
]['fields'] = [
128 'type' => CRM_Utils_Type
::T_INT
,
129 'title' => ts('State ID'),
130 'description' => ts('State/Province ID'),
132 'where' => 'civicrm_state_province.id',
133 'table_name' => 'civicrm_state_province',
134 'entity' => 'StateProvince',
135 'bao' => 'CRM_Core_DAO_StateProvince',
145 'type' => CRM_Utils_Type
::T_STRING
,
146 'title' => ts('State'),
147 'description' => ts('Name of State/Province'),
149 'size' => CRM_Utils_Type
::BIG
,
151 'where' => 'civicrm_state_province.name',
152 'headerPattern' => '/state|prov(ince)?/i',
153 'dataPattern' => '/[A-Z]{2}/',
155 'table_name' => 'civicrm_state_province',
156 'entity' => 'StateProvince',
157 'bao' => 'CRM_Core_DAO_StateProvince',
162 'name' => 'abbreviation',
163 'type' => CRM_Utils_Type
::T_STRING
,
164 'title' => ts('State Abbreviation'),
165 'description' => ts('2-4 Character Abbreviation of State/Province'),
167 'size' => CRM_Utils_Type
::FOUR
,
168 'where' => 'civicrm_state_province.abbreviation',
169 'table_name' => 'civicrm_state_province',
170 'entity' => 'StateProvince',
171 'bao' => 'CRM_Core_DAO_StateProvince',
176 'name' => 'country_id',
177 'type' => CRM_Utils_Type
::T_INT
,
178 'title' => ts('Country ID'),
179 'description' => ts('ID of Country that State/Province belong'),
181 'where' => 'civicrm_state_province.country_id',
182 'table_name' => 'civicrm_state_province',
183 'entity' => 'StateProvince',
184 'bao' => 'CRM_Core_DAO_StateProvince',
186 'FKClassName' => 'CRM_Core_DAO_Country',
188 'label' => ts("Country"),
193 'name' => 'is_active',
194 'type' => CRM_Utils_Type
::T_BOOLEAN
,
195 'title' => ts('StateProvince Is Active'),
196 'description' => ts('Is this StateProvince active?'),
198 'where' => 'civicrm_state_province.is_active',
200 'table_name' => 'civicrm_state_province',
201 'entity' => 'StateProvince',
202 'bao' => 'CRM_Core_DAO_StateProvince',
207 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
209 return Civi
::$statics[__CLASS__
]['fields'];
213 * Return a mapping from field-name to the corresponding key (as used in fields()).
216 * Array(string $name => string $uniqueName).
218 public static function &fieldKeys() {
219 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
220 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
222 return Civi
::$statics[__CLASS__
]['fieldKeys'];
226 * Returns the names of this table
230 public static function getTableName() {
231 return self
::$_tableName;
235 * Returns if this table needs to be logged
239 public function getLog() {
244 * Returns the list of fields that can be imported
246 * @param bool $prefix
250 public static function &import($prefix = FALSE) {
251 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'state_province', $prefix, []);
256 * Returns the list of fields that can be exported
258 * @param bool $prefix
262 public static function &export($prefix = FALSE) {
263 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'state_province', $prefix, []);
268 * Returns the list of indices
270 * @param bool $localize
274 public static function indices($localize = TRUE) {
276 'UI_name_country_id' => [
277 'name' => 'UI_name_country_id',
282 'localizable' => FALSE,
284 'sig' => 'civicrm_state_province::1::name::country_id',
287 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;