CRM-14885 - Import DAO's
[civicrm-core.git] / CRM / Core / DAO / StateProvince.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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-2016
30 *
31 * Generated from xml/schema/CRM/Core/StateProvince.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:eb9f2b5e6268fe81bf226acdc126d0dd)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 class CRM_Core_DAO_StateProvince extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_state_province';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 */
55 static $_fieldKeys = null;
56 /**
57 * static instance to hold the FK relationships
58 *
59 * @var string
60 */
61 static $_links = null;
62 /**
63 * static instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 */
68 static $_import = null;
69 /**
70 * static instance to hold the values that can
71 * be exported
72 *
73 * @var array
74 */
75 static $_export = null;
76 /**
77 * static value to see if we should log any modifications to
78 * this table in the civicrm_log table
79 *
80 * @var boolean
81 */
82 static $_log = false;
83 /**
84 * State/Province ID
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * Name of State/Province
91 *
92 * @var string
93 */
94 public $name;
95 /**
96 * 2-4 Character Abbreviation of State/Province
97 *
98 * @var string
99 */
100 public $abbreviation;
101 /**
102 * ID of Country that State/Province belong
103 *
104 * @var int unsigned
105 */
106 public $country_id;
107 /**
108 * class constructor
109 *
110 * @return civicrm_state_province
111 */
112 function __construct() {
113 $this->__table = 'civicrm_state_province';
114 parent::__construct();
115 }
116 /**
117 * Returns foreign keys and entity references
118 *
119 * @return array
120 * [CRM_Core_Reference_Interface]
121 */
122 static function getReferenceColumns() {
123 if (!self::$_links) {
124 self::$_links = static ::createReferenceColumns(__CLASS__);
125 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'country_id', 'civicrm_country', 'id');
126 }
127 return self::$_links;
128 }
129 /**
130 * Returns all the column names of this table
131 *
132 * @return array
133 */
134 static function &fields() {
135 if (!(self::$_fields)) {
136 self::$_fields = array(
137 'id' => array(
138 'name' => 'id',
139 'type' => CRM_Utils_Type::T_INT,
140 'title' => ts('State ID') ,
141 'description' => 'State/Province ID',
142 'required' => true,
143 ) ,
144 'name' => array(
145 'name' => 'name',
146 'type' => CRM_Utils_Type::T_STRING,
147 'title' => ts('State') ,
148 'description' => 'Name of State/Province',
149 'maxlength' => 64,
150 'size' => CRM_Utils_Type::BIG,
151 'import' => true,
152 'where' => 'civicrm_state_province.name',
153 'headerPattern' => '/state|prov(ince)?/i',
154 'dataPattern' => '/[A-Z]{2}/',
155 'export' => true,
156 ) ,
157 'abbreviation' => array(
158 'name' => 'abbreviation',
159 'type' => CRM_Utils_Type::T_STRING,
160 'title' => ts('State Abbreviation') ,
161 'description' => '2-4 Character Abbreviation of State/Province',
162 'maxlength' => 4,
163 'size' => CRM_Utils_Type::FOUR,
164 ) ,
165 'country_id' => array(
166 'name' => 'country_id',
167 'type' => CRM_Utils_Type::T_INT,
168 'title' => ts('County') ,
169 'description' => 'ID of Country that State/Province belong',
170 'required' => true,
171 'FKClassName' => 'CRM_Core_DAO_Country',
172 ) ,
173 );
174 }
175 return self::$_fields;
176 }
177 /**
178 * Returns an array containing, for each field, the arary key used for that
179 * field in self::$_fields.
180 *
181 * @return array
182 */
183 static function &fieldKeys() {
184 if (!(self::$_fieldKeys)) {
185 self::$_fieldKeys = array(
186 'id' => 'id',
187 'name' => 'name',
188 'abbreviation' => 'abbreviation',
189 'country_id' => 'country_id',
190 );
191 }
192 return self::$_fieldKeys;
193 }
194 /**
195 * Returns the names of this table
196 *
197 * @return string
198 */
199 static function getTableName() {
200 return self::$_tableName;
201 }
202 /**
203 * Returns if this table needs to be logged
204 *
205 * @return boolean
206 */
207 function getLog() {
208 return self::$_log;
209 }
210 /**
211 * Returns the list of fields that can be imported
212 *
213 * @param bool $prefix
214 *
215 * @return array
216 */
217 static function &import($prefix = false) {
218 if (!(self::$_import)) {
219 self::$_import = array();
220 $fields = self::fields();
221 foreach($fields as $name => $field) {
222 if (CRM_Utils_Array::value('import', $field)) {
223 if ($prefix) {
224 self::$_import['state_province'] = & $fields[$name];
225 } else {
226 self::$_import[$name] = & $fields[$name];
227 }
228 }
229 }
230 }
231 return self::$_import;
232 }
233 /**
234 * Returns the list of fields that can be exported
235 *
236 * @param bool $prefix
237 *
238 * @return array
239 */
240 static function &export($prefix = false) {
241 if (!(self::$_export)) {
242 self::$_export = array();
243 $fields = self::fields();
244 foreach($fields as $name => $field) {
245 if (CRM_Utils_Array::value('export', $field)) {
246 if ($prefix) {
247 self::$_export['state_province'] = & $fields[$name];
248 } else {
249 self::$_export[$name] = & $fields[$name];
250 }
251 }
252 }
253 }
254 return self::$_export;
255 }
256 }