Merge pull request #18149 from seamuslee001/dev_core_1952
[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:b2fa8ca60001d75a9049ca179c4e68ce)
10 */
11
12 /**
13 * Database access object for the MembershipPayment entity.
14 */
15 class CRM_Member_DAO_MembershipPayment extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_membership_payment';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 public static $_log = TRUE;
30
31 /**
32 * @var int
33 */
34 public $id;
35
36 /**
37 * FK to Membership table
38 *
39 * @var int
40 */
41 public $membership_id;
42
43 /**
44 * FK to contribution table.
45 *
46 * @var int
47 */
48 public $contribution_id;
49
50 /**
51 * Class constructor.
52 */
53 public function __construct() {
54 $this->__table = 'civicrm_membership_payment';
55 parent::__construct();
56 }
57
58 /**
59 * Returns localized title of this entity.
60 */
61 public static function getEntityTitle() {
62 return ts('Membership Payments');
63 }
64
65 /**
66 * Returns foreign keys and entity references.
67 *
68 * @return array
69 * [CRM_Core_Reference_Interface]
70 */
71 public static function getReferenceColumns() {
72 if (!isset(Civi::$statics[__CLASS__]['links'])) {
73 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
74 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'membership_id', 'civicrm_membership', 'id');
75 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id');
76 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
77 }
78 return Civi::$statics[__CLASS__]['links'];
79 }
80
81 /**
82 * Returns all the column names of this table
83 *
84 * @return array
85 */
86 public static function &fields() {
87 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
88 Civi::$statics[__CLASS__]['fields'] = [
89 'id' => [
90 'name' => 'id',
91 'type' => CRM_Utils_Type::T_INT,
92 'title' => ts('Membership Payment ID'),
93 'required' => TRUE,
94 'where' => 'civicrm_membership_payment.id',
95 'table_name' => 'civicrm_membership_payment',
96 'entity' => 'MembershipPayment',
97 'bao' => 'CRM_Member_BAO_MembershipPayment',
98 'localizable' => 0,
99 'add' => '1.5',
100 ],
101 'membership_id' => [
102 'name' => 'membership_id',
103 'type' => CRM_Utils_Type::T_INT,
104 'title' => ts('Membership'),
105 'description' => ts('FK to Membership table'),
106 'required' => TRUE,
107 'where' => 'civicrm_membership_payment.membership_id',
108 'table_name' => 'civicrm_membership_payment',
109 'entity' => 'MembershipPayment',
110 'bao' => 'CRM_Member_BAO_MembershipPayment',
111 'localizable' => 0,
112 'FKClassName' => 'CRM_Member_DAO_Membership',
113 'add' => '1.5',
114 ],
115 'contribution_id' => [
116 'name' => 'contribution_id',
117 'type' => CRM_Utils_Type::T_INT,
118 'title' => ts('Contribution'),
119 'description' => ts('FK to contribution table.'),
120 'where' => 'civicrm_membership_payment.contribution_id',
121 'table_name' => 'civicrm_membership_payment',
122 'entity' => 'MembershipPayment',
123 'bao' => 'CRM_Member_BAO_MembershipPayment',
124 'localizable' => 0,
125 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
126 'add' => '2.0',
127 ],
128 ];
129 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
130 }
131 return Civi::$statics[__CLASS__]['fields'];
132 }
133
134 /**
135 * Return a mapping from field-name to the corresponding key (as used in fields()).
136 *
137 * @return array
138 * Array(string $name => string $uniqueName).
139 */
140 public static function &fieldKeys() {
141 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
142 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
143 }
144 return Civi::$statics[__CLASS__]['fieldKeys'];
145 }
146
147 /**
148 * Returns the names of this table
149 *
150 * @return string
151 */
152 public static function getTableName() {
153 return self::$_tableName;
154 }
155
156 /**
157 * Returns if this table needs to be logged
158 *
159 * @return bool
160 */
161 public function getLog() {
162 return self::$_log;
163 }
164
165 /**
166 * Returns the list of fields that can be imported
167 *
168 * @param bool $prefix
169 *
170 * @return array
171 */
172 public static function &import($prefix = FALSE) {
173 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'membership_payment', $prefix, []);
174 return $r;
175 }
176
177 /**
178 * Returns the list of fields that can be exported
179 *
180 * @param bool $prefix
181 *
182 * @return array
183 */
184 public static function &export($prefix = FALSE) {
185 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'membership_payment', $prefix, []);
186 return $r;
187 }
188
189 /**
190 * Returns the list of indices
191 *
192 * @param bool $localize
193 *
194 * @return array
195 */
196 public static function indices($localize = TRUE) {
197 $indices = [
198 'UI_contribution_membership' => [
199 'name' => 'UI_contribution_membership',
200 'field' => [
201 0 => 'contribution_id',
202 1 => 'membership_id',
203 ],
204 'localizable' => FALSE,
205 'unique' => TRUE,
206 'sig' => 'civicrm_membership_payment::1::contribution_id::membership_id',
207 ],
208 ];
209 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
210 }
211
212 }