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:458e89b098dbf4f91369a293406c38ba)
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',
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',
384 'table_name' => 'civicrm_membership',
385 'entity' => 'Membership',
386 'bao' => 'CRM_Member_BAO_Membership',
392 'member_is_test' => [
394 'type' => CRM_Utils_Type
::T_BOOLEAN
,
395 'title' => ts('Test'),
397 'where' => 'civicrm_membership.is_test',
398 'headerPattern' => '/(is.)?test(.member(ship)?)?/i',
401 'table_name' => 'civicrm_membership',
402 'entity' => 'Membership',
403 'bao' => 'CRM_Member_BAO_Membership',
406 'type' => 'CheckBox',
409 'member_is_pay_later' => [
410 'name' => 'is_pay_later',
411 'type' => CRM_Utils_Type
::T_BOOLEAN
,
412 'title' => ts('Is Pay Later'),
414 'where' => 'civicrm_membership.is_pay_later',
415 'headerPattern' => '/(is.)?(pay(.)?later)$/i',
418 'table_name' => 'civicrm_membership',
419 'entity' => 'Membership',
420 'bao' => 'CRM_Member_BAO_Membership',
423 'type' => 'CheckBox',
426 'contribution_recur_id' => [
427 'name' => 'contribution_recur_id',
428 'type' => CRM_Utils_Type
::T_INT
,
429 'title' => ts('Membership Recurring Contribution'),
430 '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.'),
431 'where' => 'civicrm_membership.contribution_recur_id',
432 'table_name' => 'civicrm_membership',
433 'entity' => 'Membership',
434 'bao' => 'CRM_Member_BAO_Membership',
436 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
438 'member_campaign_id' => [
439 'name' => 'campaign_id',
440 'type' => CRM_Utils_Type
::T_INT
,
441 'title' => ts('Campaign'),
442 'description' => ts('The campaign for which this membership is attached.'),
444 'where' => 'civicrm_membership.campaign_id',
446 'table_name' => 'civicrm_membership',
447 'entity' => 'Membership',
448 'bao' => 'CRM_Member_BAO_Membership',
450 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
454 'pseudoconstant' => [
455 'table' => 'civicrm_campaign',
457 'labelColumn' => 'title',
461 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
463 return Civi
::$statics[__CLASS__
]['fields'];
467 * Return a mapping from field-name to the corresponding key (as used in fields()).
470 * Array(string $name => string $uniqueName).
472 public static function &fieldKeys() {
473 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
474 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
476 return Civi
::$statics[__CLASS__
]['fieldKeys'];
480 * Returns the names of this table
484 public static function getTableName() {
485 return self
::$_tableName;
489 * Returns if this table needs to be logged
493 public function getLog() {
498 * Returns the list of fields that can be imported
500 * @param bool $prefix
504 public static function &import($prefix = FALSE) {
505 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'membership', $prefix, []);
510 * Returns the list of fields that can be exported
512 * @param bool $prefix
516 public static function &export($prefix = FALSE) {
517 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'membership', $prefix, []);
522 * Returns the list of indices
524 * @param bool $localize
528 public static function indices($localize = TRUE) {
530 'index_owner_membership_id' => [
531 'name' => 'index_owner_membership_id',
533 0 => 'owner_membership_id',
535 'localizable' => FALSE,
536 'sig' => 'civicrm_membership::0::owner_membership_id',
539 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;