5 * @copyright CiviCRM LLC (c) 2004-2019
7 * Generated from xml/schema/CRM/Contact/Contact.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:bd37bd31a0ac8ba4fd5f411fddef080b)
13 * Database access object for the Contact entity.
15 class CRM_Contact_DAO_Contact
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_contact';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
46 * May be used to over-ride contact view and edit templates.
50 public $contact_sub_type;
78 * Has the contact opted out from receiving all bulk email from the organization or site domain?
85 * May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.
89 public $legal_identifier;
92 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
96 public $external_identifier;
99 * Name used for sorting different contact types
106 * Formatted name representing preferred format for display/print/other output.
110 public $display_name;
127 * optional URL for preferred image (photo, logo, etc.) to display for this contact.
134 * What is the preferred mode of communication.
138 public $preferred_communication_method;
141 * Which language is preferred for communication. FK to languages in civicrm_option_value.
145 public $preferred_language;
148 * What is the preferred mode of sending an email.
152 public $preferred_mail_format;
155 * Key for validating requests related to this contact.
162 * API Key for validating requests related to this contact.
169 * where contact come from, e.g. import, donate module insert...
197 * Prefix or Title for name (Ms, Mr...). FK to prefix ID
204 * Suffix for name (Jr, Sr...). FK to suffix ID
211 * Formal (academic or similar) title in front of name. (Prof., Dr. etc.)
215 public $formal_title;
218 * Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.
222 public $communication_style_id;
225 * FK to civicrm_option_value.id, that has to be valid registered Email Greeting.
229 public $email_greeting_id;
232 * Custom Email Greeting.
236 public $email_greeting_custom;
239 * Cache Email Greeting.
243 public $email_greeting_display;
246 * FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.
250 public $postal_greeting_id;
253 * Custom Postal greeting.
257 public $postal_greeting_custom;
260 * Cache Postal greeting.
264 public $postal_greeting_display;
267 * FK to civicrm_option_value.id, that has to be valid registered Addressee.
271 public $addressee_id;
278 public $addressee_custom;
285 public $addressee_display;
318 public $deceased_date;
325 public $household_name;
328 * Optional FK to Primary Contact for this household.
332 public $primary_contact_id;
339 public $organization_name;
342 * Standard Industry Classification Code.
349 * the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM
353 public $user_unique_id;
356 * OPTIONAL FK to civicrm_contact record.
368 * When was the contact was created.
372 public $created_date;
375 * When was the contact (or closely related entity) was created or modified or deleted.
379 public $modified_date;
384 public function __construct() {
385 $this->__table
= 'civicrm_contact';
386 parent
::__construct();
390 * Returns foreign keys and entity references.
393 * [CRM_Core_Reference_Interface]
395 public static function getReferenceColumns() {
396 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
397 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
398 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'primary_contact_id', 'civicrm_contact', 'id');
399 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'employer_id', 'civicrm_contact', 'id');
400 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
402 return Civi
::$statics[__CLASS__
]['links'];
406 * Returns all the column names of this table
410 public static function &fields() {
411 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
412 Civi
::$statics[__CLASS__
]['fields'] = [
415 'type' => CRM_Utils_Type
::T_INT
,
416 'title' => ts('Contact ID'),
417 'description' => ts('Unique Contact ID'),
420 'where' => 'civicrm_contact.id',
421 'headerPattern' => '/internal|contact?|id$/i',
423 'table_name' => 'civicrm_contact',
424 'entity' => 'Contact',
425 'bao' => 'CRM_Contact_BAO_Contact',
429 'name' => 'contact_type',
430 'type' => CRM_Utils_Type
::T_STRING
,
431 'title' => ts('Contact Type'),
432 'description' => ts('Type of Contact.'),
434 'size' => CRM_Utils_Type
::BIG
,
435 'where' => 'civicrm_contact.contact_type',
437 'table_name' => 'civicrm_contact',
438 'entity' => 'Contact',
439 'bao' => 'CRM_Contact_BAO_Contact',
444 'pseudoconstant' => [
445 'table' => 'civicrm_contact_type',
446 'keyColumn' => 'name',
447 'labelColumn' => 'label',
448 'condition' => 'parent_id IS NULL',
451 'contact_sub_type' => [
452 'name' => 'contact_sub_type',
453 'type' => CRM_Utils_Type
::T_STRING
,
454 'title' => ts('Contact Subtype'),
455 'description' => ts('May be used to over-ride contact view and edit templates.'),
457 'size' => CRM_Utils_Type
::HUGE
,
459 'where' => 'civicrm_contact.contact_sub_type',
460 'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
462 'table_name' => 'civicrm_contact',
463 'entity' => 'Contact',
464 'bao' => 'CRM_Contact_BAO_Contact',
466 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
470 'pseudoconstant' => [
471 'table' => 'civicrm_contact_type',
472 'keyColumn' => 'name',
473 'labelColumn' => 'label',
474 'condition' => 'parent_id IS NOT NULL',
478 'name' => 'do_not_email',
479 'type' => CRM_Utils_Type
::T_BOOLEAN
,
480 'title' => ts('Do Not Email'),
482 'where' => 'civicrm_contact.do_not_email',
483 'headerPattern' => '/d(o )?(not )?(email)/i',
484 'dataPattern' => '/^\d{1,}$/',
487 'table_name' => 'civicrm_contact',
488 'entity' => 'Contact',
489 'bao' => 'CRM_Contact_BAO_Contact',
492 'type' => 'CheckBox',
496 'name' => 'do_not_phone',
497 'type' => CRM_Utils_Type
::T_BOOLEAN
,
498 'title' => ts('Do Not Phone'),
500 'where' => 'civicrm_contact.do_not_phone',
501 'headerPattern' => '/d(o )?(not )?(call|phone)/i',
502 'dataPattern' => '/^\d{1,}$/',
505 'table_name' => 'civicrm_contact',
506 'entity' => 'Contact',
507 'bao' => 'CRM_Contact_BAO_Contact',
510 'type' => 'CheckBox',
514 'name' => 'do_not_mail',
515 'type' => CRM_Utils_Type
::T_BOOLEAN
,
516 'title' => ts('Do Not Mail'),
518 'where' => 'civicrm_contact.do_not_mail',
519 'headerPattern' => '/^(d(o\s)?n(ot\s)?mail)|(\w*)?bulk\s?(\w*)$/i',
520 'dataPattern' => '/^\d{1,}$/',
523 'table_name' => 'civicrm_contact',
524 'entity' => 'Contact',
525 'bao' => 'CRM_Contact_BAO_Contact',
528 'type' => 'CheckBox',
532 'name' => 'do_not_sms',
533 'type' => CRM_Utils_Type
::T_BOOLEAN
,
534 'title' => ts('Do Not Sms'),
536 'where' => 'civicrm_contact.do_not_sms',
537 'headerPattern' => '/d(o )?(not )?(sms)/i',
538 'dataPattern' => '/^\d{1,}$/',
541 'table_name' => 'civicrm_contact',
542 'entity' => 'Contact',
543 'bao' => 'CRM_Contact_BAO_Contact',
546 'type' => 'CheckBox',
550 'name' => 'do_not_trade',
551 'type' => CRM_Utils_Type
::T_BOOLEAN
,
552 'title' => ts('Do Not Trade'),
554 'where' => 'civicrm_contact.do_not_trade',
555 'headerPattern' => '/d(o )?(not )?(trade)/i',
556 'dataPattern' => '/^\d{1,}$/',
559 'table_name' => 'civicrm_contact',
560 'entity' => 'Contact',
561 'bao' => 'CRM_Contact_BAO_Contact',
564 'type' => 'CheckBox',
568 'name' => 'is_opt_out',
569 'type' => CRM_Utils_Type
::T_BOOLEAN
,
570 'title' => ts('No Bulk Emails (User Opt Out)'),
571 'description' => ts('Has the contact opted out from receiving all bulk email from the organization or site domain?'),
574 'where' => 'civicrm_contact.is_opt_out',
577 'table_name' => 'civicrm_contact',
578 'entity' => 'Contact',
579 'bao' => 'CRM_Contact_BAO_Contact',
582 'type' => 'CheckBox',
585 'legal_identifier' => [
586 'name' => 'legal_identifier',
587 'type' => CRM_Utils_Type
::T_STRING
,
588 'title' => ts('Legal Identifier'),
589 'description' => ts('May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.'),
591 'size' => CRM_Utils_Type
::MEDIUM
,
593 'where' => 'civicrm_contact.legal_identifier',
594 'headerPattern' => '/legal\s?id/i',
595 'dataPattern' => '/\w+?\d{5,}/',
597 'table_name' => 'civicrm_contact',
598 'entity' => 'Contact',
599 'bao' => 'CRM_Contact_BAO_Contact',
605 'external_identifier' => [
606 'name' => 'external_identifier',
607 'type' => CRM_Utils_Type
::T_STRING
,
608 'title' => ts('External Identifier'),
609 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
613 'where' => 'civicrm_contact.external_identifier',
614 'headerPattern' => '/external\s?id/i',
615 'dataPattern' => '/^\d{11,}$/',
617 'table_name' => 'civicrm_contact',
618 'entity' => 'Contact',
619 'bao' => 'CRM_Contact_BAO_Contact',
626 'name' => 'sort_name',
627 'type' => CRM_Utils_Type
::T_STRING
,
628 'title' => ts('Sort Name'),
629 'description' => ts('Name used for sorting different contact types'),
632 'where' => 'civicrm_contact.sort_name',
634 'table_name' => 'civicrm_contact',
635 'entity' => 'Contact',
636 'bao' => 'CRM_Contact_BAO_Contact',
643 'name' => 'display_name',
644 'type' => CRM_Utils_Type
::T_STRING
,
645 'title' => ts('Display Name'),
646 'description' => ts('Formatted name representing preferred format for display/print/other output.'),
649 'where' => 'civicrm_contact.display_name',
651 'table_name' => 'civicrm_contact',
652 'entity' => 'Contact',
653 'bao' => 'CRM_Contact_BAO_Contact',
660 'name' => 'nick_name',
661 'type' => CRM_Utils_Type
::T_STRING
,
662 'title' => ts('Nickname'),
663 'description' => ts('Nickname.'),
667 'where' => 'civicrm_contact.nick_name',
668 'headerPattern' => '/n(ick\s)name|nick$/i',
669 'dataPattern' => '/^\w+$/',
671 'table_name' => 'civicrm_contact',
672 'entity' => 'Contact',
673 'bao' => 'CRM_Contact_BAO_Contact',
680 'name' => 'legal_name',
681 'type' => CRM_Utils_Type
::T_STRING
,
682 'title' => ts('Legal Name'),
683 'description' => ts('Legal Name.'),
687 'where' => 'civicrm_contact.legal_name',
688 'headerPattern' => '/^legal|(l(egal\s)?name)$/i',
690 'table_name' => 'civicrm_contact',
691 'entity' => 'Contact',
692 'bao' => 'CRM_Contact_BAO_Contact',
699 'name' => 'image_URL',
700 'type' => CRM_Utils_Type
::T_TEXT
,
701 'title' => ts('Image Url'),
702 'description' => ts('optional URL for preferred image (photo, logo, etc.) to display for this contact.'),
704 'where' => 'civicrm_contact.image_URL',
706 'table_name' => 'civicrm_contact',
707 'entity' => 'Contact',
708 'bao' => 'CRM_Contact_BAO_Contact',
714 'preferred_communication_method' => [
715 'name' => 'preferred_communication_method',
716 'type' => CRM_Utils_Type
::T_STRING
,
717 'title' => ts('Preferred Communication Method'),
718 'description' => ts('What is the preferred mode of communication.'),
720 'size' => CRM_Utils_Type
::HUGE
,
722 'where' => 'civicrm_contact.preferred_communication_method',
723 'headerPattern' => '/^p(ref\w*\s)?c(omm\w*)|( meth\w*)$/i',
724 'dataPattern' => '/^\w+$/',
726 'table_name' => 'civicrm_contact',
727 'entity' => 'Contact',
728 'bao' => 'CRM_Contact_BAO_Contact',
730 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
734 'pseudoconstant' => [
735 'optionGroupName' => 'preferred_communication_method',
736 'optionEditPath' => 'civicrm/admin/options/preferred_communication_method',
739 'preferred_language' => [
740 'name' => 'preferred_language',
741 'type' => CRM_Utils_Type
::T_STRING
,
742 'title' => ts('Preferred Language'),
743 'description' => ts('Which language is preferred for communication. FK to languages in civicrm_option_value.'),
745 'size' => CRM_Utils_Type
::SIX
,
747 'where' => 'civicrm_contact.preferred_language',
748 'headerPattern' => '/^lang/i',
750 'table_name' => 'civicrm_contact',
751 'entity' => 'Contact',
752 'bao' => 'CRM_Contact_BAO_Contact',
757 'pseudoconstant' => [
758 'optionGroupName' => 'languages',
759 'keyColumn' => 'name',
760 'optionEditPath' => 'civicrm/admin/options/languages',
763 'preferred_mail_format' => [
764 'name' => 'preferred_mail_format',
765 'type' => CRM_Utils_Type
::T_STRING
,
766 'title' => ts('Preferred Mail Format'),
767 'description' => ts('What is the preferred mode of sending an email.'),
769 'size' => CRM_Utils_Type
::EIGHT
,
771 'where' => 'civicrm_contact.preferred_mail_format',
772 'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i',
775 'table_name' => 'civicrm_contact',
776 'entity' => 'Contact',
777 'bao' => 'CRM_Contact_BAO_Contact',
782 'pseudoconstant' => [
783 'callback' => 'CRM_Core_SelectValues::pmf',
788 'type' => CRM_Utils_Type
::T_STRING
,
789 'title' => ts('Contact Hash'),
790 'description' => ts('Key for validating requests related to this contact.'),
792 'size' => CRM_Utils_Type
::MEDIUM
,
793 'where' => 'civicrm_contact.hash',
795 'table_name' => 'civicrm_contact',
796 'entity' => 'Contact',
797 'bao' => 'CRM_Contact_BAO_Contact',
802 'type' => CRM_Utils_Type
::T_STRING
,
803 'title' => ts('Api Key'),
804 'description' => ts('API Key for validating requests related to this contact.'),
806 'size' => CRM_Utils_Type
::MEDIUM
,
807 'where' => 'civicrm_contact.api_key',
810 'administer CiviCRM',
814 'table_name' => 'civicrm_contact',
815 'entity' => 'Contact',
816 'bao' => 'CRM_Contact_BAO_Contact',
819 'contact_source' => [
821 'type' => CRM_Utils_Type
::T_STRING
,
822 'title' => ts('Contact Source'),
823 'description' => ts('where contact come from, e.g. import, donate module insert...'),
827 'where' => 'civicrm_contact.source',
828 'headerPattern' => '/(C(ontact\s)?Source)$/i',
830 'table_name' => 'civicrm_contact',
831 'entity' => 'Contact',
832 'bao' => 'CRM_Contact_BAO_Contact',
839 'name' => 'first_name',
840 'type' => CRM_Utils_Type
::T_STRING
,
841 'title' => ts('First Name'),
842 'description' => ts('First Name.'),
846 'where' => 'civicrm_contact.first_name',
847 'headerPattern' => '/^first|(f(irst\s)?name)$/i',
848 'dataPattern' => '/^\w+$/',
850 'table_name' => 'civicrm_contact',
851 'entity' => 'Contact',
852 'bao' => 'CRM_Contact_BAO_Contact',
859 'name' => 'middle_name',
860 'type' => CRM_Utils_Type
::T_STRING
,
861 'title' => ts('Middle Name'),
862 'description' => ts('Middle Name.'),
866 'where' => 'civicrm_contact.middle_name',
867 'headerPattern' => '/^middle|(m(iddle\s)?name)$/i',
868 'dataPattern' => '/^\w+$/',
870 'table_name' => 'civicrm_contact',
871 'entity' => 'Contact',
872 'bao' => 'CRM_Contact_BAO_Contact',
879 'name' => 'last_name',
880 'type' => CRM_Utils_Type
::T_STRING
,
881 'title' => ts('Last Name'),
882 'description' => ts('Last Name.'),
886 'where' => 'civicrm_contact.last_name',
887 'headerPattern' => '/^last|(l(ast\s)?name)$/i',
888 'dataPattern' => '/^\w+(\s\w+)?+$/',
890 'table_name' => 'civicrm_contact',
891 'entity' => 'Contact',
892 'bao' => 'CRM_Contact_BAO_Contact',
899 'name' => 'prefix_id',
900 'type' => CRM_Utils_Type
::T_INT
,
901 'title' => ts('Individual Prefix'),
902 'description' => ts('Prefix or Title for name (Ms, Mr...). FK to prefix ID'),
904 'where' => 'civicrm_contact.prefix_id',
905 'headerPattern' => '/^(prefix|title)/i',
906 'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
908 'table_name' => 'civicrm_contact',
909 'entity' => 'Contact',
910 'bao' => 'CRM_Contact_BAO_Contact',
915 'pseudoconstant' => [
916 'optionGroupName' => 'individual_prefix',
917 'optionEditPath' => 'civicrm/admin/options/individual_prefix',
921 'name' => 'suffix_id',
922 'type' => CRM_Utils_Type
::T_INT
,
923 'title' => ts('Individual Suffix'),
924 'description' => ts('Suffix for name (Jr, Sr...). FK to suffix ID'),
926 'where' => 'civicrm_contact.suffix_id',
927 'headerPattern' => '/^suffix$/i',
928 'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
930 'table_name' => 'civicrm_contact',
931 'entity' => 'Contact',
932 'bao' => 'CRM_Contact_BAO_Contact',
937 'pseudoconstant' => [
938 'optionGroupName' => 'individual_suffix',
939 'optionEditPath' => 'civicrm/admin/options/individual_suffix',
943 'name' => 'formal_title',
944 'type' => CRM_Utils_Type
::T_STRING
,
945 'title' => ts('Formal Title'),
946 'description' => ts('Formal (academic or similar) title in front of name. (Prof., Dr. etc.)'),
948 'size' => CRM_Utils_Type
::BIG
,
950 'where' => 'civicrm_contact.formal_title',
951 'headerPattern' => '/^title/i',
953 'table_name' => 'civicrm_contact',
954 'entity' => 'Contact',
955 'bao' => 'CRM_Contact_BAO_Contact',
961 'communication_style_id' => [
962 'name' => 'communication_style_id',
963 'type' => CRM_Utils_Type
::T_INT
,
964 'title' => ts('Communication Style'),
965 'description' => ts('Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.'),
966 'where' => 'civicrm_contact.communication_style_id',
968 'table_name' => 'civicrm_contact',
969 'entity' => 'Contact',
970 'bao' => 'CRM_Contact_BAO_Contact',
975 'pseudoconstant' => [
976 'optionGroupName' => 'communication_style',
977 'optionEditPath' => 'civicrm/admin/options/communication_style',
980 'email_greeting_id' => [
981 'name' => 'email_greeting_id',
982 'type' => CRM_Utils_Type
::T_INT
,
983 'title' => ts('Email Greeting ID'),
984 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Email Greeting.'),
985 'where' => 'civicrm_contact.email_greeting_id',
987 'table_name' => 'civicrm_contact',
988 'entity' => 'Contact',
989 'bao' => 'CRM_Contact_BAO_Contact',
991 'pseudoconstant' => [
992 'optionGroupName' => 'email_greeting',
993 'optionEditPath' => 'civicrm/admin/options/email_greeting',
996 'email_greeting_custom' => [
997 'name' => 'email_greeting_custom',
998 'type' => CRM_Utils_Type
::T_STRING
,
999 'title' => ts('Email Greeting Custom'),
1000 'description' => ts('Custom Email Greeting.'),
1002 'size' => CRM_Utils_Type
::HUGE
,
1004 'where' => 'civicrm_contact.email_greeting_custom',
1006 'table_name' => 'civicrm_contact',
1007 'entity' => 'Contact',
1008 'bao' => 'CRM_Contact_BAO_Contact',
1014 'email_greeting_display' => [
1015 'name' => 'email_greeting_display',
1016 'type' => CRM_Utils_Type
::T_STRING
,
1017 'title' => ts('Email Greeting'),
1018 'description' => ts('Cache Email Greeting.'),
1020 'size' => CRM_Utils_Type
::HUGE
,
1021 'where' => 'civicrm_contact.email_greeting_display',
1022 'table_name' => 'civicrm_contact',
1023 'entity' => 'Contact',
1024 'bao' => 'CRM_Contact_BAO_Contact',
1030 'postal_greeting_id' => [
1031 'name' => 'postal_greeting_id',
1032 'type' => CRM_Utils_Type
::T_INT
,
1033 'title' => ts('Postal Greeting ID'),
1034 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.'),
1035 'where' => 'civicrm_contact.postal_greeting_id',
1037 'table_name' => 'civicrm_contact',
1038 'entity' => 'Contact',
1039 'bao' => 'CRM_Contact_BAO_Contact',
1044 'pseudoconstant' => [
1045 'optionGroupName' => 'postal_greeting',
1046 'optionEditPath' => 'civicrm/admin/options/postal_greeting',
1049 'postal_greeting_custom' => [
1050 'name' => 'postal_greeting_custom',
1051 'type' => CRM_Utils_Type
::T_STRING
,
1052 'title' => ts('Postal Greeting Custom'),
1053 'description' => ts('Custom Postal greeting.'),
1055 'size' => CRM_Utils_Type
::HUGE
,
1057 'where' => 'civicrm_contact.postal_greeting_custom',
1059 'table_name' => 'civicrm_contact',
1060 'entity' => 'Contact',
1061 'bao' => 'CRM_Contact_BAO_Contact',
1067 'postal_greeting_display' => [
1068 'name' => 'postal_greeting_display',
1069 'type' => CRM_Utils_Type
::T_STRING
,
1070 'title' => ts('Postal Greeting'),
1071 'description' => ts('Cache Postal greeting.'),
1073 'size' => CRM_Utils_Type
::HUGE
,
1074 'where' => 'civicrm_contact.postal_greeting_display',
1075 'table_name' => 'civicrm_contact',
1076 'entity' => 'Contact',
1077 'bao' => 'CRM_Contact_BAO_Contact',
1084 'name' => 'addressee_id',
1085 'type' => CRM_Utils_Type
::T_INT
,
1086 'title' => ts('Addressee ID'),
1087 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Addressee.'),
1088 'where' => 'civicrm_contact.addressee_id',
1090 'table_name' => 'civicrm_contact',
1091 'entity' => 'Contact',
1092 'bao' => 'CRM_Contact_BAO_Contact',
1094 'pseudoconstant' => [
1095 'optionGroupName' => 'addressee',
1096 'optionEditPath' => 'civicrm/admin/options/addressee',
1099 'addressee_custom' => [
1100 'name' => 'addressee_custom',
1101 'type' => CRM_Utils_Type
::T_STRING
,
1102 'title' => ts('Addressee Custom'),
1103 'description' => ts('Custom Addressee.'),
1105 'size' => CRM_Utils_Type
::HUGE
,
1107 'where' => 'civicrm_contact.addressee_custom',
1109 'table_name' => 'civicrm_contact',
1110 'entity' => 'Contact',
1111 'bao' => 'CRM_Contact_BAO_Contact',
1117 'addressee_display' => [
1118 'name' => 'addressee_display',
1119 'type' => CRM_Utils_Type
::T_STRING
,
1120 'title' => ts('Addressee'),
1121 'description' => ts('Cache Addressee.'),
1123 'size' => CRM_Utils_Type
::HUGE
,
1124 'where' => 'civicrm_contact.addressee_display',
1125 'table_name' => 'civicrm_contact',
1126 'entity' => 'Contact',
1127 'bao' => 'CRM_Contact_BAO_Contact',
1134 'name' => 'job_title',
1135 'type' => CRM_Utils_Type
::T_STRING
,
1136 'title' => ts('Job Title'),
1137 'description' => ts('Job Title'),
1141 'where' => 'civicrm_contact.job_title',
1142 'headerPattern' => '/^job|(j(ob\s)?title)$/i',
1143 'dataPattern' => '//',
1145 'table_name' => 'civicrm_contact',
1146 'entity' => 'Contact',
1147 'bao' => 'CRM_Contact_BAO_Contact',
1154 'name' => 'gender_id',
1155 'type' => CRM_Utils_Type
::T_INT
,
1156 'title' => ts('Gender'),
1157 'description' => ts('FK to gender ID'),
1159 'where' => 'civicrm_contact.gender_id',
1160 'headerPattern' => '/^gender$/i',
1162 'table_name' => 'civicrm_contact',
1163 'entity' => 'Contact',
1164 'bao' => 'CRM_Contact_BAO_Contact',
1169 'pseudoconstant' => [
1170 'optionGroupName' => 'gender',
1171 'optionEditPath' => 'civicrm/admin/options/gender',
1175 'name' => 'birth_date',
1176 'type' => CRM_Utils_Type
::T_DATE
,
1177 'title' => ts('Birth Date'),
1178 'description' => ts('Date of birth'),
1180 'where' => 'civicrm_contact.birth_date',
1181 'headerPattern' => '/^birth|(b(irth\s)?date)|D(\W*)O(\W*)B(\W*)$/i',
1182 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
1184 'table_name' => 'civicrm_contact',
1185 'entity' => 'Contact',
1186 'bao' => 'CRM_Contact_BAO_Contact',
1189 'type' => 'Select Date',
1190 'formatType' => 'birth',
1194 'name' => 'is_deceased',
1195 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1196 'title' => ts('Deceased'),
1198 'where' => 'civicrm_contact.is_deceased',
1199 'headerPattern' => '/i(s\s)?d(eceased)$/i',
1202 'table_name' => 'civicrm_contact',
1203 'entity' => 'Contact',
1204 'bao' => 'CRM_Contact_BAO_Contact',
1207 'type' => 'CheckBox',
1210 'deceased_date' => [
1211 'name' => 'deceased_date',
1212 'type' => CRM_Utils_Type
::T_DATE
,
1213 'title' => ts('Deceased Date'),
1214 'description' => ts('Date of deceased'),
1216 'where' => 'civicrm_contact.deceased_date',
1217 'headerPattern' => '/^deceased|(d(eceased\s)?date)$/i',
1219 'table_name' => 'civicrm_contact',
1220 'entity' => 'Contact',
1221 'bao' => 'CRM_Contact_BAO_Contact',
1224 'type' => 'Select Date',
1225 'formatType' => 'birth',
1228 'household_name' => [
1229 'name' => 'household_name',
1230 'type' => CRM_Utils_Type
::T_STRING
,
1231 'title' => ts('Household Name'),
1232 'description' => ts('Household Name.'),
1236 'where' => 'civicrm_contact.household_name',
1237 'headerPattern' => '/^household|(h(ousehold\s)?name)$/i',
1238 'dataPattern' => '/^\w+$/',
1240 'table_name' => 'civicrm_contact',
1241 'entity' => 'Contact',
1242 'bao' => 'CRM_Contact_BAO_Contact',
1248 'primary_contact_id' => [
1249 'name' => 'primary_contact_id',
1250 'type' => CRM_Utils_Type
::T_INT
,
1251 'title' => ts('Household Primary Contact ID'),
1252 'description' => ts('Optional FK to Primary Contact for this household.'),
1253 'where' => 'civicrm_contact.primary_contact_id',
1254 'table_name' => 'civicrm_contact',
1255 'entity' => 'Contact',
1256 'bao' => 'CRM_Contact_BAO_Contact',
1258 'FKClassName' => 'CRM_Contact_DAO_Contact',
1263 'organization_name' => [
1264 'name' => 'organization_name',
1265 'type' => CRM_Utils_Type
::T_STRING
,
1266 'title' => ts('Organization Name'),
1267 'description' => ts('Organization Name.'),
1271 'where' => 'civicrm_contact.organization_name',
1272 'headerPattern' => '/^organization|(o(rganization\s)?name)$/i',
1273 'dataPattern' => '/^\w+$/',
1275 'table_name' => 'civicrm_contact',
1276 'entity' => 'Contact',
1277 'bao' => 'CRM_Contact_BAO_Contact',
1284 'name' => 'sic_code',
1285 'type' => CRM_Utils_Type
::T_STRING
,
1286 'title' => ts('Sic Code'),
1287 'description' => ts('Standard Industry Classification Code.'),
1289 'size' => CRM_Utils_Type
::EIGHT
,
1291 'where' => 'civicrm_contact.sic_code',
1292 'headerPattern' => '/^sic|(s(ic\s)?code)$/i',
1294 'table_name' => 'civicrm_contact',
1295 'entity' => 'Contact',
1296 'bao' => 'CRM_Contact_BAO_Contact',
1302 'user_unique_id' => [
1303 'name' => 'user_unique_id',
1304 'type' => CRM_Utils_Type
::T_STRING
,
1305 'title' => ts('Unique ID (OpenID)'),
1306 'description' => ts('the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM'),
1308 'size' => CRM_Utils_Type
::HUGE
,
1310 'where' => 'civicrm_contact.user_unique_id',
1311 'headerPattern' => '/^Open\s?ID|u(niq\w*)?\s?ID/i',
1312 'dataPattern' => '/^[\w\/\:\.]+$/',
1315 'table_name' => 'civicrm_contact',
1316 'entity' => 'Contact',
1317 'bao' => 'CRM_Contact_BAO_Contact',
1323 'current_employer_id' => [
1324 'name' => 'employer_id',
1325 'type' => CRM_Utils_Type
::T_INT
,
1326 'title' => ts('Current Employer'),
1327 'description' => ts('OPTIONAL FK to civicrm_contact record.'),
1328 'where' => 'civicrm_contact.employer_id',
1330 'table_name' => 'civicrm_contact',
1331 'entity' => 'Contact',
1332 'bao' => 'CRM_Contact_BAO_Contact',
1334 'FKClassName' => 'CRM_Contact_DAO_Contact',
1336 'type' => 'EntityRef',
1339 'contact_is_deleted' => [
1340 'name' => 'is_deleted',
1341 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1342 'title' => ts('Contact is in Trash'),
1344 'where' => 'civicrm_contact.is_deleted',
1347 'table_name' => 'civicrm_contact',
1348 'entity' => 'Contact',
1349 'bao' => 'CRM_Contact_BAO_Contact',
1352 'type' => 'CheckBox',
1356 'name' => 'created_date',
1357 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1358 'title' => ts('Created Date'),
1359 'description' => ts('When was the contact was created.'),
1360 'required' => FALSE,
1361 'where' => 'civicrm_contact.created_date',
1363 'default' => 'NULL',
1364 'table_name' => 'civicrm_contact',
1365 'entity' => 'Contact',
1366 'bao' => 'CRM_Contact_BAO_Contact',
1369 'modified_date' => [
1370 'name' => 'modified_date',
1371 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1372 'title' => ts('Modified Date'),
1373 'description' => ts('When was the contact (or closely related entity) was created or modified or deleted.'),
1374 'required' => FALSE,
1375 'where' => 'civicrm_contact.modified_date',
1377 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
1378 'table_name' => 'civicrm_contact',
1379 'entity' => 'Contact',
1380 'bao' => 'CRM_Contact_BAO_Contact',
1384 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
1386 return Civi
::$statics[__CLASS__
]['fields'];
1390 * Return a mapping from field-name to the corresponding key (as used in fields()).
1393 * Array(string $name => string $uniqueName).
1395 public static function &fieldKeys() {
1396 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
1397 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
1399 return Civi
::$statics[__CLASS__
]['fieldKeys'];
1403 * Returns the names of this table
1407 public static function getTableName() {
1408 return self
::$_tableName;
1412 * Returns if this table needs to be logged
1416 public function getLog() {
1421 * Returns the list of fields that can be imported
1423 * @param bool $prefix
1427 public static function &import($prefix = FALSE) {
1428 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contact', $prefix, []);
1433 * Returns the list of fields that can be exported
1435 * @param bool $prefix
1439 public static function &export($prefix = FALSE) {
1440 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contact', $prefix, []);
1445 * Returns the list of indices
1447 * @param bool $localize
1451 public static function indices($localize = TRUE) {
1453 'index_contact_type' => [
1454 'name' => 'index_contact_type',
1456 0 => 'contact_type',
1458 'localizable' => FALSE,
1459 'sig' => 'civicrm_contact::0::contact_type',
1461 'index_contact_sub_type' => [
1462 'name' => 'index_contact_sub_type',
1464 0 => 'contact_sub_type',
1466 'localizable' => FALSE,
1467 'sig' => 'civicrm_contact::0::contact_sub_type',
1469 'UI_external_identifier' => [
1470 'name' => 'UI_external_identifier',
1472 0 => 'external_identifier',
1474 'localizable' => FALSE,
1476 'sig' => 'civicrm_contact::1::external_identifier',
1478 'index_sort_name' => [
1479 'name' => 'index_sort_name',
1483 'localizable' => FALSE,
1484 'sig' => 'civicrm_contact::0::sort_name',
1486 'index_preferred_communication_method' => [
1487 'name' => 'index_preferred_communication_method',
1489 0 => 'preferred_communication_method',
1491 'localizable' => FALSE,
1492 'sig' => 'civicrm_contact::0::preferred_communication_method',
1495 'name' => 'index_hash',
1499 'localizable' => FALSE,
1500 'sig' => 'civicrm_contact::0::hash',
1502 'index_api_key' => [
1503 'name' => 'index_api_key',
1507 'localizable' => FALSE,
1508 'sig' => 'civicrm_contact::0::api_key',
1510 'index_first_name' => [
1511 'name' => 'index_first_name',
1515 'localizable' => FALSE,
1516 'sig' => 'civicrm_contact::0::first_name',
1518 'index_last_name' => [
1519 'name' => 'index_last_name',
1523 'localizable' => FALSE,
1524 'sig' => 'civicrm_contact::0::last_name',
1527 'name' => 'UI_prefix',
1531 'localizable' => FALSE,
1532 'sig' => 'civicrm_contact::0::prefix_id',
1535 'name' => 'UI_suffix',
1539 'localizable' => FALSE,
1540 'sig' => 'civicrm_contact::0::suffix_id',
1542 'index_communication_style_id' => [
1543 'name' => 'index_communication_style_id',
1545 0 => 'communication_style_id',
1547 'localizable' => FALSE,
1548 'sig' => 'civicrm_contact::0::communication_style_id',
1551 'name' => 'UI_gender',
1555 'localizable' => FALSE,
1556 'sig' => 'civicrm_contact::0::gender_id',
1558 'index_is_deceased' => [
1559 'name' => 'index_is_deceased',
1563 'localizable' => FALSE,
1564 'sig' => 'civicrm_contact::0::is_deceased',
1566 'index_household_name' => [
1567 'name' => 'index_household_name',
1569 0 => 'household_name',
1571 'localizable' => FALSE,
1572 'sig' => 'civicrm_contact::0::household_name',
1574 'index_organization_name' => [
1575 'name' => 'index_organization_name',
1577 0 => 'organization_name',
1579 'localizable' => FALSE,
1580 'sig' => 'civicrm_contact::0::organization_name',
1582 'index_is_deleted_sort_name' => [
1583 'name' => 'index_is_deleted_sort_name',
1589 'localizable' => FALSE,
1590 'sig' => 'civicrm_contact::0::is_deleted::sort_name::id',
1593 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;