5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Member/Membership.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:8a676a436711b85a6c7228e6566a12fc)
13 * Database access object for the Membership entity.
15 class CRM_Member_DAO_Membership
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_membership';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
46 * FK to Membership Type
50 public $membership_type_id;
53 * Beginning of initial membership period (member since...).
60 * Beginning of current uninterrupted membership period.
67 * Current membership period expire date.
79 * FK to Membership Status
86 * Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.
93 * Then end date of membership status override if 'Override until selected date' override type is selected.
97 public $status_override_end_date;
100 * Optional FK to Parent Membership.
104 public $owner_membership_id;
107 * Maximum number of related memberships (membership_type override).
121 public $is_pay_later;
124 * Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.
128 public $contribution_recur_id;
131 * The campaign for which this membership is attached.
140 public function __construct() {
141 $this->__table
= 'civicrm_membership';
142 parent
::__construct();
146 * Returns foreign keys and entity references.
149 * [CRM_Core_Reference_Interface]
151 public static function getReferenceColumns() {
152 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
153 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
154 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
155 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'membership_type_id', 'civicrm_membership_type', 'id');
156 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'status_id', 'civicrm_membership_status', 'id');
157 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'owner_membership_id', 'civicrm_membership', 'id');
158 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_recur_id', 'civicrm_contribution_recur', 'id');
159 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
160 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
162 return Civi
::$statics[__CLASS__
]['links'];
166 * Returns all the column names of this table
170 public static function &fields() {
171 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
172 Civi
::$statics[__CLASS__
]['fields'] = [
175 'type' => CRM_Utils_Type
::T_INT
,
176 'title' => ts('Membership ID'),
177 'description' => ts('Membership Id'),
180 'where' => 'civicrm_membership.id',
181 'headerPattern' => '/^(m(embership\s)?id)$/i',
183 'table_name' => 'civicrm_membership',
184 'entity' => 'Membership',
185 'bao' => 'CRM_Member_BAO_Membership',
188 'membership_contact_id' => [
189 'name' => 'contact_id',
190 'type' => CRM_Utils_Type
::T_INT
,
191 'title' => ts('Contact ID'),
192 'description' => ts('FK to Contact ID'),
195 'where' => 'civicrm_membership.contact_id',
196 'headerPattern' => '/contact(.?id)?/i',
197 'dataPattern' => '/^\d+$/',
199 'table_name' => 'civicrm_membership',
200 'entity' => 'Membership',
201 'bao' => 'CRM_Member_BAO_Membership',
203 'FKClassName' => 'CRM_Contact_DAO_Contact',
205 'type' => 'EntityRef',
208 'membership_type_id' => [
209 'name' => 'membership_type_id',
210 'type' => CRM_Utils_Type
::T_INT
,
211 'title' => ts('Membership Type Id'),
212 'description' => ts('FK to Membership Type'),
215 'where' => 'civicrm_membership.membership_type_id',
216 'headerPattern' => '/^(m(embership\s)?type)$/i',
218 'table_name' => 'civicrm_membership',
219 'entity' => 'Membership',
220 'bao' => 'CRM_Member_BAO_Membership',
222 'FKClassName' => 'CRM_Member_DAO_MembershipType',
225 'label' => ts("Membership Type"),
227 'pseudoconstant' => [
228 'table' => 'civicrm_membership_type',
230 'labelColumn' => 'name',
233 'membership_join_date' => [
234 'name' => 'join_date',
235 'type' => CRM_Utils_Type
::T_DATE
,
236 'title' => ts('Member Since'),
237 'description' => ts('Beginning of initial membership period (member since...).'),
239 'where' => 'civicrm_membership.join_date',
240 'headerPattern' => '/^join|(j(oin\s)?date)$/i',
241 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
243 'table_name' => 'civicrm_membership',
244 'entity' => 'Membership',
245 'bao' => 'CRM_Member_BAO_Membership',
248 'type' => 'Select Date',
249 'formatType' => 'activityDate',
252 'membership_start_date' => [
253 'name' => 'start_date',
254 'type' => CRM_Utils_Type
::T_DATE
,
255 'title' => ts('Membership Start Date'),
256 'description' => ts('Beginning of current uninterrupted membership period.'),
258 'where' => 'civicrm_membership.start_date',
259 'headerPattern' => '/(member(ship)?.)?start(s)?(.date$)?/i',
260 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
262 'table_name' => 'civicrm_membership',
263 'entity' => 'Membership',
264 'bao' => 'CRM_Member_BAO_Membership',
267 'type' => 'Select Date',
268 'formatType' => 'activityDate',
271 'membership_end_date' => [
272 'name' => 'end_date',
273 'type' => CRM_Utils_Type
::T_DATE
,
274 'title' => ts('Membership Expiration Date'),
275 'description' => ts('Current membership period expire date.'),
277 'where' => 'civicrm_membership.end_date',
278 'headerPattern' => '/(member(ship)?.)?end(s)?(.date$)?/i',
279 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
281 'table_name' => 'civicrm_membership',
282 'entity' => 'Membership',
283 'bao' => 'CRM_Member_BAO_Membership',
286 'type' => 'Select Date',
287 'formatType' => 'activityDate',
290 'membership_source' => [
292 'type' => CRM_Utils_Type
::T_STRING
,
293 'title' => ts('Source'),
295 'size' => CRM_Utils_Type
::HUGE
,
297 'where' => 'civicrm_membership.source',
298 'headerPattern' => '/^(member(ship?))?source$/i',
300 'table_name' => 'civicrm_membership',
301 'entity' => 'Membership',
302 'bao' => 'CRM_Member_BAO_Membership',
309 'name' => 'status_id',
310 'type' => CRM_Utils_Type
::T_INT
,
311 'title' => ts('Membership Status Id'),
312 'description' => ts('FK to Membership Status'),
315 'where' => 'civicrm_membership.status_id',
316 'headerPattern' => '/(member(ship|).)?(status)$/i',
318 'table_name' => 'civicrm_membership',
319 'entity' => 'Membership',
320 'bao' => 'CRM_Member_BAO_Membership',
322 'FKClassName' => 'CRM_Member_DAO_MembershipStatus',
326 'pseudoconstant' => [
327 'table' => 'civicrm_membership_status',
329 'labelColumn' => 'label',
332 'member_is_override' => [
333 'name' => 'is_override',
334 'type' => CRM_Utils_Type
::T_BOOLEAN
,
335 'title' => ts('Status Override'),
336 'description' => ts('Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.'),
338 'where' => 'civicrm_membership.is_override',
339 'headerPattern' => '/override$/i',
341 'table_name' => 'civicrm_membership',
342 'entity' => 'Membership',
343 'bao' => 'CRM_Member_BAO_Membership',
346 'type' => 'CheckBox',
349 'status_override_end_date' => [
350 'name' => 'status_override_end_date',
351 'type' => CRM_Utils_Type
::T_DATE
,
352 'title' => ts('Status Override End Date'),
353 'description' => ts('Then end date of membership status override if \'Override until selected date\' override type is selected.'),
355 'where' => 'civicrm_membership.status_override_end_date',
358 'table_name' => 'civicrm_membership',
359 'entity' => 'Membership',
360 'bao' => 'CRM_Member_BAO_Membership',
363 'type' => 'Select Date',
366 'owner_membership_id' => [
367 'name' => 'owner_membership_id',
368 'type' => CRM_Utils_Type
::T_INT
,
369 'title' => ts('Primary Member ID'),
370 'description' => ts('Optional FK to Parent Membership.'),
371 'where' => 'civicrm_membership.owner_membership_id',
373 'table_name' => 'civicrm_membership',
374 'entity' => 'Membership',
375 'bao' => 'CRM_Member_BAO_Membership',
377 'FKClassName' => 'CRM_Member_DAO_Membership',
380 'name' => 'max_related',
381 'type' => CRM_Utils_Type
::T_INT
,
382 'title' => ts('Max Related'),
383 'description' => ts('Maximum number of related memberships (membership_type override).'),
384 'where' => 'civicrm_membership.max_related',
386 'table_name' => 'civicrm_membership',
387 'entity' => 'Membership',
388 'bao' => 'CRM_Member_BAO_Membership',
394 'member_is_test' => [
396 'type' => CRM_Utils_Type
::T_BOOLEAN
,
397 'title' => ts('Test'),
399 'where' => 'civicrm_membership.is_test',
400 'headerPattern' => '/(is.)?test(.member(ship)?)?/i',
403 'table_name' => 'civicrm_membership',
404 'entity' => 'Membership',
405 'bao' => 'CRM_Member_BAO_Membership',
408 'type' => 'CheckBox',
411 'member_is_pay_later' => [
412 'name' => 'is_pay_later',
413 'type' => CRM_Utils_Type
::T_BOOLEAN
,
414 'title' => ts('Is Pay Later'),
416 'where' => 'civicrm_membership.is_pay_later',
417 'headerPattern' => '/(is.)?(pay(.)?later)$/i',
420 'table_name' => 'civicrm_membership',
421 'entity' => 'Membership',
422 'bao' => 'CRM_Member_BAO_Membership',
425 'type' => 'CheckBox',
428 'membership_recur_id' => [
429 'name' => 'contribution_recur_id',
430 'type' => CRM_Utils_Type
::T_INT
,
431 'title' => ts('Membership Recurring Contribution'),
432 'description' => ts('Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.'),
433 'where' => 'civicrm_membership.contribution_recur_id',
435 'table_name' => 'civicrm_membership',
436 'entity' => 'Membership',
437 'bao' => 'CRM_Member_BAO_Membership',
439 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
441 'member_campaign_id' => [
442 'name' => 'campaign_id',
443 'type' => CRM_Utils_Type
::T_INT
,
444 'title' => ts('Campaign'),
445 'description' => ts('The campaign for which this membership is attached.'),
447 'where' => 'civicrm_membership.campaign_id',
449 'table_name' => 'civicrm_membership',
450 'entity' => 'Membership',
451 'bao' => 'CRM_Member_BAO_Membership',
453 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
457 'pseudoconstant' => [
458 'table' => 'civicrm_campaign',
460 'labelColumn' => 'title',
464 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
466 return Civi
::$statics[__CLASS__
]['fields'];
470 * Return a mapping from field-name to the corresponding key (as used in fields()).
473 * Array(string $name => string $uniqueName).
475 public static function &fieldKeys() {
476 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
477 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
479 return Civi
::$statics[__CLASS__
]['fieldKeys'];
483 * Returns the names of this table
487 public static function getTableName() {
488 return self
::$_tableName;
492 * Returns if this table needs to be logged
496 public function getLog() {
501 * Returns the list of fields that can be imported
503 * @param bool $prefix
507 public static function &import($prefix = FALSE) {
508 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'membership', $prefix, []);
513 * Returns the list of fields that can be exported
515 * @param bool $prefix
519 public static function &export($prefix = FALSE) {
520 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'membership', $prefix, []);
525 * Returns the list of indices
527 * @param bool $localize
531 public static function indices($localize = TRUE) {
533 'index_owner_membership_id' => [
534 'name' => 'index_owner_membership_id',
536 0 => 'owner_membership_id',
538 'localizable' => FALSE,
539 'sig' => 'civicrm_membership::0::owner_membership_id',
542 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;