5 * @copyright CiviCRM LLC (c) 2004-2019
7 * Generated from xml/schema/CRM/Member/Membership.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:40f3b0813c1e13fab544ae1f8fa2ebb3)
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',
226 'pseudoconstant' => [
227 'table' => 'civicrm_membership_type',
229 'labelColumn' => 'name',
233 'name' => 'join_date',
234 'type' => CRM_Utils_Type
::T_DATE
,
235 'title' => ts('Member Since'),
236 'description' => ts('Beginning of initial membership period (member since...).'),
238 'where' => 'civicrm_membership.join_date',
239 'headerPattern' => '/^join|(j(oin\s)?date)$/i',
240 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
242 'table_name' => 'civicrm_membership',
243 'entity' => 'Membership',
244 'bao' => 'CRM_Member_BAO_Membership',
247 'type' => 'Select Date',
248 'formatType' => 'activityDate',
251 'membership_start_date' => [
252 'name' => 'start_date',
253 'type' => CRM_Utils_Type
::T_DATE
,
254 'title' => ts('Membership Start Date'),
255 'description' => ts('Beginning of current uninterrupted membership period.'),
257 'where' => 'civicrm_membership.start_date',
258 'headerPattern' => '/(member(ship)?.)?start(s)?(.date$)?/i',
259 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
261 'table_name' => 'civicrm_membership',
262 'entity' => 'Membership',
263 'bao' => 'CRM_Member_BAO_Membership',
266 'type' => 'Select Date',
267 'formatType' => 'activityDate',
270 'membership_end_date' => [
271 'name' => 'end_date',
272 'type' => CRM_Utils_Type
::T_DATE
,
273 'title' => ts('Membership Expiration Date'),
274 'description' => ts('Current membership period expire date.'),
276 'where' => 'civicrm_membership.end_date',
277 'headerPattern' => '/(member(ship)?.)?end(s)?(.date$)?/i',
278 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
280 'table_name' => 'civicrm_membership',
281 'entity' => 'Membership',
282 'bao' => 'CRM_Member_BAO_Membership',
285 'type' => 'Select Date',
286 'formatType' => 'activityDate',
289 'membership_source' => [
291 'type' => CRM_Utils_Type
::T_STRING
,
292 'title' => ts('Source'),
294 'size' => CRM_Utils_Type
::HUGE
,
296 'where' => 'civicrm_membership.source',
297 'headerPattern' => '/^(member(ship?))?source$/i',
299 'table_name' => 'civicrm_membership',
300 'entity' => 'Membership',
301 'bao' => 'CRM_Member_BAO_Membership',
308 'name' => 'status_id',
309 'type' => CRM_Utils_Type
::T_INT
,
310 'title' => ts('Membership Status Id'),
311 'description' => ts('FK to Membership Status'),
314 'where' => 'civicrm_membership.status_id',
315 'headerPattern' => '/(member(ship|).)?(status)$/i',
317 'table_name' => 'civicrm_membership',
318 'entity' => 'Membership',
319 'bao' => 'CRM_Member_BAO_Membership',
321 'FKClassName' => 'CRM_Member_DAO_MembershipStatus',
325 'pseudoconstant' => [
326 'table' => 'civicrm_membership_status',
328 'labelColumn' => 'label',
331 'member_is_override' => [
332 'name' => 'is_override',
333 'type' => CRM_Utils_Type
::T_BOOLEAN
,
334 'title' => ts('Status Override'),
335 '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.'),
337 'where' => 'civicrm_membership.is_override',
338 'headerPattern' => '/override$/i',
340 'table_name' => 'civicrm_membership',
341 'entity' => 'Membership',
342 'bao' => 'CRM_Member_BAO_Membership',
345 'type' => 'CheckBox',
348 'status_override_end_date' => [
349 'name' => 'status_override_end_date',
350 'type' => CRM_Utils_Type
::T_DATE
,
351 'title' => ts('Status Override End Date'),
352 'description' => ts('Then end date of membership status override if \'Override until selected date\' override type is selected.'),
354 'where' => 'civicrm_membership.status_override_end_date',
357 'table_name' => 'civicrm_membership',
358 'entity' => 'Membership',
359 'bao' => 'CRM_Member_BAO_Membership',
362 'type' => 'Select Date',
365 'owner_membership_id' => [
366 'name' => 'owner_membership_id',
367 'type' => CRM_Utils_Type
::T_INT
,
368 'title' => ts('Primary Member ID'),
369 'description' => ts('Optional FK to Parent Membership.'),
370 'where' => 'civicrm_membership.owner_membership_id',
372 'table_name' => 'civicrm_membership',
373 'entity' => 'Membership',
374 'bao' => 'CRM_Member_BAO_Membership',
376 'FKClassName' => 'CRM_Member_DAO_Membership',
379 'name' => 'max_related',
380 'type' => CRM_Utils_Type
::T_INT
,
381 'title' => ts('Max Related'),
382 'description' => ts('Maximum number of related memberships (membership_type override).'),
383 'where' => 'civicrm_membership.max_related',
385 'table_name' => 'civicrm_membership',
386 'entity' => 'Membership',
387 'bao' => 'CRM_Member_BAO_Membership',
393 'member_is_test' => [
395 'type' => CRM_Utils_Type
::T_BOOLEAN
,
396 'title' => ts('Test'),
398 'where' => 'civicrm_membership.is_test',
399 'headerPattern' => '/(is.)?test(.member(ship)?)?/i',
402 'table_name' => 'civicrm_membership',
403 'entity' => 'Membership',
404 'bao' => 'CRM_Member_BAO_Membership',
407 'type' => 'CheckBox',
410 'member_is_pay_later' => [
411 'name' => 'is_pay_later',
412 'type' => CRM_Utils_Type
::T_BOOLEAN
,
413 'title' => ts('Is Pay Later'),
415 'where' => 'civicrm_membership.is_pay_later',
416 'headerPattern' => '/(is.)?(pay(.)?later)$/i',
419 'table_name' => 'civicrm_membership',
420 'entity' => 'Membership',
421 'bao' => 'CRM_Member_BAO_Membership',
424 'type' => 'CheckBox',
427 'membership_recur_id' => [
428 'name' => 'contribution_recur_id',
429 'type' => CRM_Utils_Type
::T_INT
,
430 'title' => ts('Membership Recurring Contribution'),
431 '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.'),
432 'where' => 'civicrm_membership.contribution_recur_id',
434 'table_name' => 'civicrm_membership',
435 'entity' => 'Membership',
436 'bao' => 'CRM_Member_BAO_Membership',
438 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
440 'member_campaign_id' => [
441 'name' => 'campaign_id',
442 'type' => CRM_Utils_Type
::T_INT
,
443 'title' => ts('Campaign'),
444 'description' => ts('The campaign for which this membership is attached.'),
446 'where' => 'civicrm_membership.campaign_id',
448 'table_name' => 'civicrm_membership',
449 'entity' => 'Membership',
450 'bao' => 'CRM_Member_BAO_Membership',
452 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
456 'pseudoconstant' => [
457 'table' => 'civicrm_campaign',
459 'labelColumn' => 'title',
463 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
465 return Civi
::$statics[__CLASS__
]['fields'];
469 * Return a mapping from field-name to the corresponding key (as used in fields()).
472 * Array(string $name => string $uniqueName).
474 public static function &fieldKeys() {
475 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
476 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
478 return Civi
::$statics[__CLASS__
]['fieldKeys'];
482 * Returns the names of this table
486 public static function getTableName() {
487 return self
::$_tableName;
491 * Returns if this table needs to be logged
495 public function getLog() {
500 * Returns the list of fields that can be imported
502 * @param bool $prefix
506 public static function &import($prefix = FALSE) {
507 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'membership', $prefix, []);
512 * Returns the list of fields that can be exported
514 * @param bool $prefix
518 public static function &export($prefix = FALSE) {
519 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'membership', $prefix, []);
524 * Returns the list of indices
526 * @param bool $localize
530 public static function indices($localize = TRUE) {
532 'index_owner_membership_id' => [
533 'name' => 'index_owner_membership_id',
535 0 => 'owner_membership_id',
537 'localizable' => FALSE,
538 'sig' => 'civicrm_membership::0::owner_membership_id',
541 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;