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