Merge pull request #20471 from eileenmcnaughton/schema
[civicrm-core.git] / CRM / Event / Cart / DAO / Cart.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Event/Cart/Cart.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:889446482ab589edebb02d7abee76bc5)
10 */
11
12 /**
13 * Database access object for the Cart entity.
14 */
15 class CRM_Event_Cart_DAO_Cart extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '';
18 const COMPONENT = 'CiviEvent';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_event_carts';
26
27 /**
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 *
30 * @var bool
31 */
32 public static $_log = FALSE;
33
34 /**
35 * Cart ID
36 *
37 * @var int
38 */
39 public $id;
40
41 /**
42 * FK to civicrm_contact who created this cart
43 *
44 * @var int
45 */
46 public $user_id;
47
48 /**
49 * @var bool
50 */
51 public $completed;
52
53 /**
54 * Class constructor.
55 */
56 public function __construct() {
57 $this->__table = 'civicrm_event_carts';
58 parent::__construct();
59 }
60
61 /**
62 * Returns localized title of this entity.
63 *
64 * @param bool $plural
65 * Whether to return the plural version of the title.
66 */
67 public static function getEntityTitle($plural = FALSE) {
68 return $plural ? ts('Carts') : ts('Cart');
69 }
70
71 /**
72 * Returns foreign keys and entity references.
73 *
74 * @return array
75 * [CRM_Core_Reference_Interface]
76 */
77 public static function getReferenceColumns() {
78 if (!isset(Civi::$statics[__CLASS__]['links'])) {
79 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
80 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'user_id', 'civicrm_contact', 'id');
81 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
82 }
83 return Civi::$statics[__CLASS__]['links'];
84 }
85
86 /**
87 * Returns all the column names of this table
88 *
89 * @return array
90 */
91 public static function &fields() {
92 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
93 Civi::$statics[__CLASS__]['fields'] = [
94 'cart_id' => [
95 'name' => 'id',
96 'type' => CRM_Utils_Type::T_INT,
97 'title' => ts('Cart ID'),
98 'description' => ts('Cart ID'),
99 'required' => TRUE,
100 'where' => 'civicrm_event_carts.id',
101 'table_name' => 'civicrm_event_carts',
102 'entity' => 'Cart',
103 'bao' => 'CRM_Event_Cart_BAO_Cart',
104 'localizable' => 0,
105 'html' => [
106 'type' => 'Number',
107 ],
108 'readonly' => TRUE,
109 'add' => '4.1',
110 ],
111 'user_id' => [
112 'name' => 'user_id',
113 'type' => CRM_Utils_Type::T_INT,
114 'title' => ts('Created By Contact ID'),
115 'description' => ts('FK to civicrm_contact who created this cart'),
116 'where' => 'civicrm_event_carts.user_id',
117 'table_name' => 'civicrm_event_carts',
118 'entity' => 'Cart',
119 'bao' => 'CRM_Event_Cart_BAO_Cart',
120 'localizable' => 0,
121 'FKClassName' => 'CRM_Contact_DAO_Contact',
122 'html' => [
123 'label' => ts("Created By"),
124 ],
125 'add' => '4.1',
126 ],
127 'completed' => [
128 'name' => 'completed',
129 'type' => CRM_Utils_Type::T_BOOLEAN,
130 'title' => ts('Complete?'),
131 'where' => 'civicrm_event_carts.completed',
132 'default' => '0',
133 'table_name' => 'civicrm_event_carts',
134 'entity' => 'Cart',
135 'bao' => 'CRM_Event_Cart_BAO_Cart',
136 'localizable' => 0,
137 'add' => '4.1',
138 ],
139 ];
140 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
141 }
142 return Civi::$statics[__CLASS__]['fields'];
143 }
144
145 /**
146 * Return a mapping from field-name to the corresponding key (as used in fields()).
147 *
148 * @return array
149 * Array(string $name => string $uniqueName).
150 */
151 public static function &fieldKeys() {
152 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
153 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
154 }
155 return Civi::$statics[__CLASS__]['fieldKeys'];
156 }
157
158 /**
159 * Returns the names of this table
160 *
161 * @return string
162 */
163 public static function getTableName() {
164 return self::$_tableName;
165 }
166
167 /**
168 * Returns if this table needs to be logged
169 *
170 * @return bool
171 */
172 public function getLog() {
173 return self::$_log;
174 }
175
176 /**
177 * Returns the list of fields that can be imported
178 *
179 * @param bool $prefix
180 *
181 * @return array
182 */
183 public static function &import($prefix = FALSE) {
184 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'event_carts', $prefix, []);
185 return $r;
186 }
187
188 /**
189 * Returns the list of fields that can be exported
190 *
191 * @param bool $prefix
192 *
193 * @return array
194 */
195 public static function &export($prefix = FALSE) {
196 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'event_carts', $prefix, []);
197 return $r;
198 }
199
200 /**
201 * Returns the list of indices
202 *
203 * @param bool $localize
204 *
205 * @return array
206 */
207 public static function indices($localize = TRUE) {
208 $indices = [];
209 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
210 }
211
212 }