Merge pull request #9653 from jmcclelland/CRM-19847
[civicrm-core.git] / CRM / Core / DAO / StateProvince.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27 /**
28 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2017
30 *
31 * Generated from xml/schema/CRM/Core/StateProvince.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:70c072816098c4cbd13b7c13218c35e8)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Core_DAO_StateProvince constructor.
39 */
40 class CRM_Core_DAO_StateProvince extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_state_province';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
49 *
50 * @var boolean
51 */
52 static $_log = false;
53 /**
54 * State/Province ID
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * Name of State/Province
61 *
62 * @var string
63 */
64 public $name;
65 /**
66 * 2-4 Character Abbreviation of State/Province
67 *
68 * @var string
69 */
70 public $abbreviation;
71 /**
72 * ID of Country that State/Province belong
73 *
74 * @var int unsigned
75 */
76 public $country_id;
77 /**
78 * Class constructor.
79 */
80 function __construct() {
81 $this->__table = 'civicrm_state_province';
82 parent::__construct();
83 }
84 /**
85 * Returns foreign keys and entity references.
86 *
87 * @return array
88 * [CRM_Core_Reference_Interface]
89 */
90 static function getReferenceColumns() {
91 if (!isset(Civi::$statics[__CLASS__]['links'])) {
92 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
93 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'country_id', 'civicrm_country', 'id');
94 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
95 }
96 return Civi::$statics[__CLASS__]['links'];
97 }
98 /**
99 * Returns all the column names of this table
100 *
101 * @return array
102 */
103 static function &fields() {
104 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
105 Civi::$statics[__CLASS__]['fields'] = array(
106 'id' => array(
107 'name' => 'id',
108 'type' => CRM_Utils_Type::T_INT,
109 'title' => ts('State ID') ,
110 'description' => 'State/Province ID',
111 'required' => true,
112 ) ,
113 'name' => array(
114 'name' => 'name',
115 'type' => CRM_Utils_Type::T_STRING,
116 'title' => ts('State') ,
117 'description' => 'Name of State/Province',
118 'maxlength' => 64,
119 'size' => CRM_Utils_Type::BIG,
120 'import' => true,
121 'where' => 'civicrm_state_province.name',
122 'headerPattern' => '/state|prov(ince)?/i',
123 'dataPattern' => '/[A-Z]{2}/',
124 'export' => true,
125 ) ,
126 'abbreviation' => array(
127 'name' => 'abbreviation',
128 'type' => CRM_Utils_Type::T_STRING,
129 'title' => ts('State Abbreviation') ,
130 'description' => '2-4 Character Abbreviation of State/Province',
131 'maxlength' => 4,
132 'size' => CRM_Utils_Type::FOUR,
133 ) ,
134 'country_id' => array(
135 'name' => 'country_id',
136 'type' => CRM_Utils_Type::T_INT,
137 'title' => ts('Country') ,
138 'description' => 'ID of Country that State/Province belong',
139 'required' => true,
140 'FKClassName' => 'CRM_Core_DAO_Country',
141 ) ,
142 );
143 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
144 }
145 return Civi::$statics[__CLASS__]['fields'];
146 }
147 /**
148 * Return a mapping from field-name to the corresponding key (as used in fields()).
149 *
150 * @return array
151 * Array(string $name => string $uniqueName).
152 */
153 static function &fieldKeys() {
154 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
155 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
156 }
157 return Civi::$statics[__CLASS__]['fieldKeys'];
158 }
159 /**
160 * Returns the names of this table
161 *
162 * @return string
163 */
164 static function getTableName() {
165 return self::$_tableName;
166 }
167 /**
168 * Returns if this table needs to be logged
169 *
170 * @return boolean
171 */
172 function getLog() {
173 return self::$_log;
174 }
175 /**
176 * Returns the list of fields that can be imported
177 *
178 * @param bool $prefix
179 *
180 * @return array
181 */
182 static function &import($prefix = false) {
183 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'state_province', $prefix, array());
184 return $r;
185 }
186 /**
187 * Returns the list of fields that can be exported
188 *
189 * @param bool $prefix
190 *
191 * @return array
192 */
193 static function &export($prefix = false) {
194 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'state_province', $prefix, array());
195 return $r;
196 }
197 }