Merge pull request #22483 from eileenmcnaughton/token1
[civicrm-core.git] / CRM / Member / DAO / MembershipPayment.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Member/MembershipPayment.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ff33ff800a373cf9cf5e58ad1d5a3c94)
10 */
11
12 /**
13 * Database access object for the MembershipPayment entity.
14 */
15 class CRM_Member_DAO_MembershipPayment extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.5';
18 const COMPONENT = 'CiviMember';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_membership_payment';
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 = TRUE;
33
34 /**
35 * @var int|string|null
36 * (SQL type: int unsigned)
37 * Note that values will be retrieved from the database as a string.
38 */
39 public $id;
40
41 /**
42 * FK to Membership table
43 *
44 * @var int|string
45 * (SQL type: int unsigned)
46 * Note that values will be retrieved from the database as a string.
47 */
48 public $membership_id;
49
50 /**
51 * FK to contribution table.
52 *
53 * @var int|string|null
54 * (SQL type: int unsigned)
55 * Note that values will be retrieved from the database as a string.
56 */
57 public $contribution_id;
58
59 /**
60 * Class constructor.
61 */
62 public function __construct() {
63 $this->__table = 'civicrm_membership_payment';
64 parent::__construct();
65 }
66
67 /**
68 * Returns localized title of this entity.
69 *
70 * @param bool $plural
71 * Whether to return the plural version of the title.
72 */
73 public static function getEntityTitle($plural = FALSE) {
74 return $plural ? ts('Membership Payments') : ts('Membership Payment');
75 }
76
77 /**
78 * Returns foreign keys and entity references.
79 *
80 * @return array
81 * [CRM_Core_Reference_Interface]
82 */
83 public static function getReferenceColumns() {
84 if (!isset(Civi::$statics[__CLASS__]['links'])) {
85 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
86 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'membership_id', 'civicrm_membership', 'id');
87 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id');
88 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
89 }
90 return Civi::$statics[__CLASS__]['links'];
91 }
92
93 /**
94 * Returns all the column names of this table
95 *
96 * @return array
97 */
98 public static function &fields() {
99 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
100 Civi::$statics[__CLASS__]['fields'] = [
101 'id' => [
102 'name' => 'id',
103 'type' => CRM_Utils_Type::T_INT,
104 'title' => ts('Membership Payment ID'),
105 'required' => TRUE,
106 'where' => 'civicrm_membership_payment.id',
107 'table_name' => 'civicrm_membership_payment',
108 'entity' => 'MembershipPayment',
109 'bao' => 'CRM_Member_BAO_MembershipPayment',
110 'localizable' => 0,
111 'html' => [
112 'type' => 'Number',
113 ],
114 'readonly' => TRUE,
115 'add' => '1.5',
116 ],
117 'membership_id' => [
118 'name' => 'membership_id',
119 'type' => CRM_Utils_Type::T_INT,
120 'title' => ts('Membership ID'),
121 'description' => ts('FK to Membership table'),
122 'required' => TRUE,
123 'where' => 'civicrm_membership_payment.membership_id',
124 'table_name' => 'civicrm_membership_payment',
125 'entity' => 'MembershipPayment',
126 'bao' => 'CRM_Member_BAO_MembershipPayment',
127 'localizable' => 0,
128 'FKClassName' => 'CRM_Member_DAO_Membership',
129 'html' => [
130 'label' => ts("Membership"),
131 ],
132 'add' => '1.5',
133 ],
134 'contribution_id' => [
135 'name' => 'contribution_id',
136 'type' => CRM_Utils_Type::T_INT,
137 'title' => ts('Contribution ID'),
138 'description' => ts('FK to contribution table.'),
139 'where' => 'civicrm_membership_payment.contribution_id',
140 'table_name' => 'civicrm_membership_payment',
141 'entity' => 'MembershipPayment',
142 'bao' => 'CRM_Member_BAO_MembershipPayment',
143 'localizable' => 0,
144 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
145 'html' => [
146 'label' => ts("Contribution"),
147 ],
148 'add' => '2.0',
149 ],
150 ];
151 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
152 }
153 return Civi::$statics[__CLASS__]['fields'];
154 }
155
156 /**
157 * Return a mapping from field-name to the corresponding key (as used in fields()).
158 *
159 * @return array
160 * Array(string $name => string $uniqueName).
161 */
162 public static function &fieldKeys() {
163 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
164 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
165 }
166 return Civi::$statics[__CLASS__]['fieldKeys'];
167 }
168
169 /**
170 * Returns the names of this table
171 *
172 * @return string
173 */
174 public static function getTableName() {
175 return self::$_tableName;
176 }
177
178 /**
179 * Returns if this table needs to be logged
180 *
181 * @return bool
182 */
183 public function getLog() {
184 return self::$_log;
185 }
186
187 /**
188 * Returns the list of fields that can be imported
189 *
190 * @param bool $prefix
191 *
192 * @return array
193 */
194 public static function &import($prefix = FALSE) {
195 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'membership_payment', $prefix, []);
196 return $r;
197 }
198
199 /**
200 * Returns the list of fields that can be exported
201 *
202 * @param bool $prefix
203 *
204 * @return array
205 */
206 public static function &export($prefix = FALSE) {
207 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'membership_payment', $prefix, []);
208 return $r;
209 }
210
211 /**
212 * Returns the list of indices
213 *
214 * @param bool $localize
215 *
216 * @return array
217 */
218 public static function indices($localize = TRUE) {
219 $indices = [
220 'UI_contribution_membership' => [
221 'name' => 'UI_contribution_membership',
222 'field' => [
223 0 => 'contribution_id',
224 1 => 'membership_id',
225 ],
226 'localizable' => FALSE,
227 'unique' => TRUE,
228 'sig' => 'civicrm_membership_payment::1::contribution_id::membership_id',
229 ],
230 ];
231 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
232 }
233
234 }