Merge pull request #17679 from civicrm/5.27
[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:a1d90b50f82493fea93ba2236877fb45)
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 ],
100 'membership_id' => [
101 'name' => 'membership_id',
102 'type' => CRM_Utils_Type::T_INT,
103 'title' => ts('Membership'),
104 'description' => ts('FK to Membership table'),
105 'required' => TRUE,
106 'where' => 'civicrm_membership_payment.membership_id',
107 'table_name' => 'civicrm_membership_payment',
108 'entity' => 'MembershipPayment',
109 'bao' => 'CRM_Member_BAO_MembershipPayment',
110 'localizable' => 0,
111 'FKClassName' => 'CRM_Member_DAO_Membership',
112 ],
113 'contribution_id' => [
114 'name' => 'contribution_id',
115 'type' => CRM_Utils_Type::T_INT,
116 'title' => ts('Contribution'),
117 'description' => ts('FK to contribution table.'),
118 'where' => 'civicrm_membership_payment.contribution_id',
119 'table_name' => 'civicrm_membership_payment',
120 'entity' => 'MembershipPayment',
121 'bao' => 'CRM_Member_BAO_MembershipPayment',
122 'localizable' => 0,
123 'FKClassName' => 'CRM_Contribute_DAO_Contribution',
124 ],
125 ];
126 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
127 }
128 return Civi::$statics[__CLASS__]['fields'];
129 }
130
131 /**
132 * Return a mapping from field-name to the corresponding key (as used in fields()).
133 *
134 * @return array
135 * Array(string $name => string $uniqueName).
136 */
137 public static function &fieldKeys() {
138 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
139 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
140 }
141 return Civi::$statics[__CLASS__]['fieldKeys'];
142 }
143
144 /**
145 * Returns the names of this table
146 *
147 * @return string
148 */
149 public static function getTableName() {
150 return self::$_tableName;
151 }
152
153 /**
154 * Returns if this table needs to be logged
155 *
156 * @return bool
157 */
158 public function getLog() {
159 return self::$_log;
160 }
161
162 /**
163 * Returns the list of fields that can be imported
164 *
165 * @param bool $prefix
166 *
167 * @return array
168 */
169 public static function &import($prefix = FALSE) {
170 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'membership_payment', $prefix, []);
171 return $r;
172 }
173
174 /**
175 * Returns the list of fields that can be exported
176 *
177 * @param bool $prefix
178 *
179 * @return array
180 */
181 public static function &export($prefix = FALSE) {
182 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'membership_payment', $prefix, []);
183 return $r;
184 }
185
186 /**
187 * Returns the list of indices
188 *
189 * @param bool $localize
190 *
191 * @return array
192 */
193 public static function indices($localize = TRUE) {
194 $indices = [
195 'UI_contribution_membership' => [
196 'name' => 'UI_contribution_membership',
197 'field' => [
198 0 => 'contribution_id',
199 1 => 'membership_id',
200 ],
201 'localizable' => FALSE,
202 'unique' => TRUE,
203 'sig' => 'civicrm_membership_payment::1::contribution_id::membership_id',
204 ],
205 ];
206 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
207 }
208
209 }