5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contact/Contact.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:6d8b87302a9cecf71150fc71ca3879dd)
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 * Icon associated with this entity.
29 public static $_icon = 'fa-address-book-o';
32 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 public static $_log = TRUE;
53 * May be used to over-ride contact view and edit templates.
57 public $contact_sub_type;
85 * Has the contact opted out from receiving all bulk email from the organization or site domain?
92 * May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.
96 public $legal_identifier;
99 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
103 public $external_identifier;
106 * Name used for sorting different contact types
113 * Formatted name representing preferred format for display/print/other output.
117 public $display_name;
134 * optional URL for preferred image (photo, logo, etc.) to display for this contact.
141 * What is the preferred mode of communication.
145 public $preferred_communication_method;
148 * Which language is preferred for communication. FK to languages in civicrm_option_value.
152 public $preferred_language;
155 * What is the preferred mode of sending an email.
159 public $preferred_mail_format;
162 * Key for validating requests related to this contact.
169 * API Key for validating requests related to this contact.
176 * where contact come from, e.g. import, donate module insert...
204 * Prefix or Title for name (Ms, Mr...). FK to prefix ID
211 * Suffix for name (Jr, Sr...). FK to suffix ID
218 * Formal (academic or similar) title in front of name. (Prof., Dr. etc.)
222 public $formal_title;
225 * Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.
229 public $communication_style_id;
232 * FK to civicrm_option_value.id, that has to be valid registered Email Greeting.
236 public $email_greeting_id;
239 * Custom Email Greeting.
243 public $email_greeting_custom;
246 * Cache Email Greeting.
250 public $email_greeting_display;
253 * FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.
257 public $postal_greeting_id;
260 * Custom Postal greeting.
264 public $postal_greeting_custom;
267 * Cache Postal greeting.
271 public $postal_greeting_display;
274 * FK to civicrm_option_value.id, that has to be valid registered Addressee.
278 public $addressee_id;
285 public $addressee_custom;
292 public $addressee_display;
325 public $deceased_date;
332 public $household_name;
335 * Optional FK to Primary Contact for this household.
339 public $primary_contact_id;
346 public $organization_name;
349 * Standard Industry Classification Code.
356 * the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM
360 public $user_unique_id;
363 * OPTIONAL FK to civicrm_contact record.
375 * When was the contact was created.
379 public $created_date;
382 * When was the contact (or closely related entity) was created or modified or deleted.
386 public $modified_date;
391 public function __construct() {
392 $this->__table
= 'civicrm_contact';
393 parent
::__construct();
397 * Returns localized title of this entity.
399 public static function getEntityTitle() {
400 return ts('Contacts');
404 * Returns foreign keys and entity references.
407 * [CRM_Core_Reference_Interface]
409 public static function getReferenceColumns() {
410 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
411 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
412 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'primary_contact_id', 'civicrm_contact', 'id');
413 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'employer_id', 'civicrm_contact', 'id');
414 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
416 return Civi
::$statics[__CLASS__
]['links'];
420 * Returns all the column names of this table
424 public static function &fields() {
425 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
426 Civi
::$statics[__CLASS__
]['fields'] = [
429 'type' => CRM_Utils_Type
::T_INT
,
430 'title' => ts('Contact ID'),
431 'description' => ts('Unique Contact ID'),
434 'where' => 'civicrm_contact.id',
435 'headerPattern' => '/internal|contact?|id$/i',
437 'table_name' => 'civicrm_contact',
438 'entity' => 'Contact',
439 'bao' => 'CRM_Contact_BAO_Contact',
443 'name' => 'contact_type',
444 'type' => CRM_Utils_Type
::T_STRING
,
445 'title' => ts('Contact Type'),
446 'description' => ts('Type of Contact.'),
448 'size' => CRM_Utils_Type
::BIG
,
449 'where' => 'civicrm_contact.contact_type',
451 'contactType' => NULL,
452 'table_name' => 'civicrm_contact',
453 'entity' => 'Contact',
454 'bao' => 'CRM_Contact_BAO_Contact',
459 'pseudoconstant' => [
460 'table' => 'civicrm_contact_type',
461 'keyColumn' => 'name',
462 'labelColumn' => 'label',
463 'condition' => 'parent_id IS NULL',
466 'contact_sub_type' => [
467 'name' => 'contact_sub_type',
468 'type' => CRM_Utils_Type
::T_STRING
,
469 'title' => ts('Contact Subtype'),
470 'description' => ts('May be used to over-ride contact view and edit templates.'),
472 'size' => CRM_Utils_Type
::HUGE
,
474 'where' => 'civicrm_contact.contact_sub_type',
475 'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
477 'table_name' => 'civicrm_contact',
478 'entity' => 'Contact',
479 'bao' => 'CRM_Contact_BAO_Contact',
481 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
485 'pseudoconstant' => [
486 'table' => 'civicrm_contact_type',
487 'keyColumn' => 'name',
488 'labelColumn' => 'label',
489 'condition' => 'parent_id IS NOT NULL',
493 'name' => 'do_not_email',
494 'type' => CRM_Utils_Type
::T_BOOLEAN
,
495 'title' => ts('Do Not Email'),
497 'where' => 'civicrm_contact.do_not_email',
498 'headerPattern' => '/d(o )?(not )?(email)/i',
499 'dataPattern' => '/^\d{1,}$/',
502 'table_name' => 'civicrm_contact',
503 'entity' => 'Contact',
504 'bao' => 'CRM_Contact_BAO_Contact',
507 'type' => 'CheckBox',
511 'name' => 'do_not_phone',
512 'type' => CRM_Utils_Type
::T_BOOLEAN
,
513 'title' => ts('Do Not Phone'),
515 'where' => 'civicrm_contact.do_not_phone',
516 'headerPattern' => '/d(o )?(not )?(call|phone)/i',
517 'dataPattern' => '/^\d{1,}$/',
520 'table_name' => 'civicrm_contact',
521 'entity' => 'Contact',
522 'bao' => 'CRM_Contact_BAO_Contact',
525 'type' => 'CheckBox',
529 'name' => 'do_not_mail',
530 'type' => CRM_Utils_Type
::T_BOOLEAN
,
531 'title' => ts('Do Not Mail'),
533 'where' => 'civicrm_contact.do_not_mail',
534 'headerPattern' => '/^(d(o\s)?n(ot\s)?mail)|(\w*)?bulk\s?(\w*)$/i',
535 'dataPattern' => '/^\d{1,}$/',
538 'table_name' => 'civicrm_contact',
539 'entity' => 'Contact',
540 'bao' => 'CRM_Contact_BAO_Contact',
543 'type' => 'CheckBox',
547 'name' => 'do_not_sms',
548 'type' => CRM_Utils_Type
::T_BOOLEAN
,
549 'title' => ts('Do Not Sms'),
551 'where' => 'civicrm_contact.do_not_sms',
552 'headerPattern' => '/d(o )?(not )?(sms)/i',
553 'dataPattern' => '/^\d{1,}$/',
556 'table_name' => 'civicrm_contact',
557 'entity' => 'Contact',
558 'bao' => 'CRM_Contact_BAO_Contact',
561 'type' => 'CheckBox',
565 'name' => 'do_not_trade',
566 'type' => CRM_Utils_Type
::T_BOOLEAN
,
567 'title' => ts('Do Not Trade'),
569 'where' => 'civicrm_contact.do_not_trade',
570 'headerPattern' => '/d(o )?(not )?(trade)/i',
571 'dataPattern' => '/^\d{1,}$/',
574 'table_name' => 'civicrm_contact',
575 'entity' => 'Contact',
576 'bao' => 'CRM_Contact_BAO_Contact',
579 'type' => 'CheckBox',
583 'name' => 'is_opt_out',
584 'type' => CRM_Utils_Type
::T_BOOLEAN
,
585 'title' => ts('No Bulk Emails (User Opt Out)'),
586 'description' => ts('Has the contact opted out from receiving all bulk email from the organization or site domain?'),
589 'where' => 'civicrm_contact.is_opt_out',
592 'table_name' => 'civicrm_contact',
593 'entity' => 'Contact',
594 'bao' => 'CRM_Contact_BAO_Contact',
597 'type' => 'CheckBox',
600 'legal_identifier' => [
601 'name' => 'legal_identifier',
602 'type' => CRM_Utils_Type
::T_STRING
,
603 'title' => ts('Legal Identifier'),
604 'description' => ts('May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.'),
606 'size' => CRM_Utils_Type
::MEDIUM
,
608 'where' => 'civicrm_contact.legal_identifier',
609 'headerPattern' => '/legal\s?id/i',
610 'dataPattern' => '/\w+?\d{5,}/',
612 'table_name' => 'civicrm_contact',
613 'entity' => 'Contact',
614 'bao' => 'CRM_Contact_BAO_Contact',
620 'external_identifier' => [
621 'name' => 'external_identifier',
622 'type' => CRM_Utils_Type
::T_STRING
,
623 'title' => ts('External Identifier'),
624 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
628 'where' => 'civicrm_contact.external_identifier',
629 'headerPattern' => '/external\s?id/i',
630 'dataPattern' => '/^\d{11,}$/',
632 'table_name' => 'civicrm_contact',
633 'entity' => 'Contact',
634 'bao' => 'CRM_Contact_BAO_Contact',
641 'name' => 'sort_name',
642 'type' => CRM_Utils_Type
::T_STRING
,
643 'title' => ts('Sort Name'),
644 'description' => ts('Name used for sorting different contact types'),
647 'where' => 'civicrm_contact.sort_name',
649 'table_name' => 'civicrm_contact',
650 'entity' => 'Contact',
651 'bao' => 'CRM_Contact_BAO_Contact',
658 'name' => 'display_name',
659 'type' => CRM_Utils_Type
::T_STRING
,
660 'title' => ts('Display Name'),
661 'description' => ts('Formatted name representing preferred format for display/print/other output.'),
664 'where' => 'civicrm_contact.display_name',
666 'table_name' => 'civicrm_contact',
667 'entity' => 'Contact',
668 'bao' => 'CRM_Contact_BAO_Contact',
675 'name' => 'nick_name',
676 'type' => CRM_Utils_Type
::T_STRING
,
677 'title' => ts('Nickname'),
678 'description' => ts('Nickname.'),
682 'where' => 'civicrm_contact.nick_name',
683 'headerPattern' => '/n(ick\s)name|nick$/i',
684 'dataPattern' => '/^\w+$/',
686 'table_name' => 'civicrm_contact',
687 'entity' => 'Contact',
688 'bao' => 'CRM_Contact_BAO_Contact',
695 'name' => 'legal_name',
696 'type' => CRM_Utils_Type
::T_STRING
,
697 'title' => ts('Legal Name'),
698 'description' => ts('Legal Name.'),
702 'where' => 'civicrm_contact.legal_name',
703 'headerPattern' => '/^legal|(l(egal\s)?name)$/i',
705 'contactType' => 'Organization',
706 'table_name' => 'civicrm_contact',
707 'entity' => 'Contact',
708 'bao' => 'CRM_Contact_BAO_Contact',
715 'name' => 'image_URL',
716 'type' => CRM_Utils_Type
::T_TEXT
,
717 'title' => ts('Image Url'),
718 'description' => ts('optional URL for preferred image (photo, logo, etc.) to display for this contact.'),
720 'where' => 'civicrm_contact.image_URL',
722 'table_name' => 'civicrm_contact',
723 'entity' => 'Contact',
724 'bao' => 'CRM_Contact_BAO_Contact',
730 'preferred_communication_method' => [
731 'name' => 'preferred_communication_method',
732 'type' => CRM_Utils_Type
::T_STRING
,
733 'title' => ts('Preferred Communication Method'),
734 'description' => ts('What is the preferred mode of communication.'),
736 'size' => CRM_Utils_Type
::HUGE
,
738 'where' => 'civicrm_contact.preferred_communication_method',
739 'headerPattern' => '/^p(ref\w*\s)?c(omm\w*)|( meth\w*)$/i',
740 'dataPattern' => '/^\w+$/',
742 'table_name' => 'civicrm_contact',
743 'entity' => 'Contact',
744 'bao' => 'CRM_Contact_BAO_Contact',
746 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
750 'pseudoconstant' => [
751 'optionGroupName' => 'preferred_communication_method',
752 'optionEditPath' => 'civicrm/admin/options/preferred_communication_method',
755 'preferred_language' => [
756 'name' => 'preferred_language',
757 'type' => CRM_Utils_Type
::T_STRING
,
758 'title' => ts('Preferred Language'),
759 'description' => ts('Which language is preferred for communication. FK to languages in civicrm_option_value.'),
761 'size' => CRM_Utils_Type
::SIX
,
763 'where' => 'civicrm_contact.preferred_language',
764 'headerPattern' => '/^lang/i',
766 'table_name' => 'civicrm_contact',
767 'entity' => 'Contact',
768 'bao' => 'CRM_Contact_BAO_Contact',
773 'pseudoconstant' => [
774 'optionGroupName' => 'languages',
775 'keyColumn' => 'name',
776 'optionEditPath' => 'civicrm/admin/options/languages',
779 'preferred_mail_format' => [
780 'name' => 'preferred_mail_format',
781 'type' => CRM_Utils_Type
::T_STRING
,
782 'title' => ts('Preferred Mail Format'),
783 'description' => ts('What is the preferred mode of sending an email.'),
785 'size' => CRM_Utils_Type
::EIGHT
,
787 'where' => 'civicrm_contact.preferred_mail_format',
788 'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i',
791 'table_name' => 'civicrm_contact',
792 'entity' => 'Contact',
793 'bao' => 'CRM_Contact_BAO_Contact',
798 'pseudoconstant' => [
799 'callback' => 'CRM_Core_SelectValues::pmf',
804 'type' => CRM_Utils_Type
::T_STRING
,
805 'title' => ts('Contact Hash'),
806 'description' => ts('Key for validating requests related to this contact.'),
808 'size' => CRM_Utils_Type
::MEDIUM
,
809 'where' => 'civicrm_contact.hash',
811 'table_name' => 'civicrm_contact',
812 'entity' => 'Contact',
813 'bao' => 'CRM_Contact_BAO_Contact',
818 'type' => CRM_Utils_Type
::T_STRING
,
819 'title' => ts('Api Key'),
820 'description' => ts('API Key for validating requests related to this contact.'),
822 'size' => CRM_Utils_Type
::MEDIUM
,
823 'where' => 'civicrm_contact.api_key',
826 'administer CiviCRM',
830 'table_name' => 'civicrm_contact',
831 'entity' => 'Contact',
832 'bao' => 'CRM_Contact_BAO_Contact',
835 'contact_source' => [
837 'type' => CRM_Utils_Type
::T_STRING
,
838 'title' => ts('Contact Source'),
839 'description' => ts('where contact come from, e.g. import, donate module insert...'),
843 'where' => 'civicrm_contact.source',
844 'headerPattern' => '/(C(ontact\s)?Source)$/i',
846 'table_name' => 'civicrm_contact',
847 'entity' => 'Contact',
848 'bao' => 'CRM_Contact_BAO_Contact',
855 'name' => 'first_name',
856 'type' => CRM_Utils_Type
::T_STRING
,
857 'title' => ts('First Name'),
858 'description' => ts('First Name.'),
862 'where' => 'civicrm_contact.first_name',
863 'headerPattern' => '/^first|(f(irst\s)?name)$/i',
864 'dataPattern' => '/^\w+$/',
866 'contactType' => 'Individual',
867 'table_name' => 'civicrm_contact',
868 'entity' => 'Contact',
869 'bao' => 'CRM_Contact_BAO_Contact',
876 'name' => 'middle_name',
877 'type' => CRM_Utils_Type
::T_STRING
,
878 'title' => ts('Middle Name'),
879 'description' => ts('Middle Name.'),
883 'where' => 'civicrm_contact.middle_name',
884 'headerPattern' => '/^middle|(m(iddle\s)?name)$/i',
885 'dataPattern' => '/^\w+$/',
887 'contactType' => 'Individual',
888 'table_name' => 'civicrm_contact',
889 'entity' => 'Contact',
890 'bao' => 'CRM_Contact_BAO_Contact',
897 'name' => 'last_name',
898 'type' => CRM_Utils_Type
::T_STRING
,
899 'title' => ts('Last Name'),
900 'description' => ts('Last Name.'),
904 'where' => 'civicrm_contact.last_name',
905 'headerPattern' => '/^last|(l(ast\s)?name)$/i',
906 'dataPattern' => '/^\w+(\s\w+)?+$/',
908 'contactType' => 'Individual',
909 'table_name' => 'civicrm_contact',
910 'entity' => 'Contact',
911 'bao' => 'CRM_Contact_BAO_Contact',
918 'name' => 'prefix_id',
919 'type' => CRM_Utils_Type
::T_INT
,
920 'title' => ts('Individual Prefix'),
921 'description' => ts('Prefix or Title for name (Ms, Mr...). FK to prefix ID'),
923 'where' => 'civicrm_contact.prefix_id',
924 'headerPattern' => '/^(prefix|title)/i',
925 'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
927 'contactType' => 'Individual',
928 'table_name' => 'civicrm_contact',
929 'entity' => 'Contact',
930 'bao' => 'CRM_Contact_BAO_Contact',
935 'pseudoconstant' => [
936 'optionGroupName' => 'individual_prefix',
937 'optionEditPath' => 'civicrm/admin/options/individual_prefix',
941 'name' => 'suffix_id',
942 'type' => CRM_Utils_Type
::T_INT
,
943 'title' => ts('Individual Suffix'),
944 'description' => ts('Suffix for name (Jr, Sr...). FK to suffix ID'),
946 'where' => 'civicrm_contact.suffix_id',
947 'headerPattern' => '/^suffix$/i',
948 'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
950 'contactType' => 'Individual',
951 'table_name' => 'civicrm_contact',
952 'entity' => 'Contact',
953 'bao' => 'CRM_Contact_BAO_Contact',
958 'pseudoconstant' => [
959 'optionGroupName' => 'individual_suffix',
960 'optionEditPath' => 'civicrm/admin/options/individual_suffix',
964 'name' => 'formal_title',
965 'type' => CRM_Utils_Type
::T_STRING
,
966 'title' => ts('Formal Title'),
967 'description' => ts('Formal (academic or similar) title in front of name. (Prof., Dr. etc.)'),
969 'size' => CRM_Utils_Type
::BIG
,
971 'where' => 'civicrm_contact.formal_title',
972 'headerPattern' => '/^title/i',
974 'contactType' => 'Individual',
975 'table_name' => 'civicrm_contact',
976 'entity' => 'Contact',
977 'bao' => 'CRM_Contact_BAO_Contact',
983 'communication_style_id' => [
984 'name' => 'communication_style_id',
985 'type' => CRM_Utils_Type
::T_INT
,
986 'title' => ts('Communication Style'),
987 'description' => ts('Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.'),
989 'where' => 'civicrm_contact.communication_style_id',
990 'headerPattern' => '/style/i',
992 'table_name' => 'civicrm_contact',
993 'entity' => 'Contact',
994 'bao' => 'CRM_Contact_BAO_Contact',
999 'pseudoconstant' => [
1000 'optionGroupName' => 'communication_style',
1001 'optionEditPath' => 'civicrm/admin/options/communication_style',
1004 'email_greeting_id' => [
1005 'name' => 'email_greeting_id',
1006 'type' => CRM_Utils_Type
::T_INT
,
1007 'title' => ts('Email Greeting ID'),
1008 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Email Greeting.'),
1009 'where' => 'civicrm_contact.email_greeting_id',
1011 'table_name' => 'civicrm_contact',
1012 'entity' => 'Contact',
1013 'bao' => 'CRM_Contact_BAO_Contact',
1018 'pseudoconstant' => [
1019 'optionGroupName' => 'email_greeting',
1020 'optionEditPath' => 'civicrm/admin/options/email_greeting',
1023 'email_greeting_custom' => [
1024 'name' => 'email_greeting_custom',
1025 'type' => CRM_Utils_Type
::T_STRING
,
1026 'title' => ts('Email Greeting Custom'),
1027 'description' => ts('Custom Email Greeting.'),
1029 'size' => CRM_Utils_Type
::HUGE
,
1031 'where' => 'civicrm_contact.email_greeting_custom',
1033 'table_name' => 'civicrm_contact',
1034 'entity' => 'Contact',
1035 'bao' => 'CRM_Contact_BAO_Contact',
1041 'email_greeting_display' => [
1042 'name' => 'email_greeting_display',
1043 'type' => CRM_Utils_Type
::T_STRING
,
1044 'title' => ts('Email Greeting'),
1045 'description' => ts('Cache Email Greeting.'),
1047 'size' => CRM_Utils_Type
::HUGE
,
1048 'where' => 'civicrm_contact.email_greeting_display',
1049 'table_name' => 'civicrm_contact',
1050 'entity' => 'Contact',
1051 'bao' => 'CRM_Contact_BAO_Contact',
1054 'postal_greeting_id' => [
1055 'name' => 'postal_greeting_id',
1056 'type' => CRM_Utils_Type
::T_INT
,
1057 'title' => ts('Postal Greeting ID'),
1058 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.'),
1059 'where' => 'civicrm_contact.postal_greeting_id',
1061 'table_name' => 'civicrm_contact',
1062 'entity' => 'Contact',
1063 'bao' => 'CRM_Contact_BAO_Contact',
1068 'pseudoconstant' => [
1069 'optionGroupName' => 'postal_greeting',
1070 'optionEditPath' => 'civicrm/admin/options/postal_greeting',
1073 'postal_greeting_custom' => [
1074 'name' => 'postal_greeting_custom',
1075 'type' => CRM_Utils_Type
::T_STRING
,
1076 'title' => ts('Postal Greeting Custom'),
1077 'description' => ts('Custom Postal greeting.'),
1079 'size' => CRM_Utils_Type
::HUGE
,
1081 'where' => 'civicrm_contact.postal_greeting_custom',
1083 'table_name' => 'civicrm_contact',
1084 'entity' => 'Contact',
1085 'bao' => 'CRM_Contact_BAO_Contact',
1091 'postal_greeting_display' => [
1092 'name' => 'postal_greeting_display',
1093 'type' => CRM_Utils_Type
::T_STRING
,
1094 'title' => ts('Postal Greeting'),
1095 'description' => ts('Cache Postal greeting.'),
1097 'size' => CRM_Utils_Type
::HUGE
,
1098 'where' => 'civicrm_contact.postal_greeting_display',
1099 'table_name' => 'civicrm_contact',
1100 'entity' => 'Contact',
1101 'bao' => 'CRM_Contact_BAO_Contact',
1105 'name' => 'addressee_id',
1106 'type' => CRM_Utils_Type
::T_INT
,
1107 'title' => ts('Addressee ID'),
1108 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Addressee.'),
1109 'where' => 'civicrm_contact.addressee_id',
1111 'table_name' => 'civicrm_contact',
1112 'entity' => 'Contact',
1113 'bao' => 'CRM_Contact_BAO_Contact',
1118 'pseudoconstant' => [
1119 'optionGroupName' => 'addressee',
1120 'optionEditPath' => 'civicrm/admin/options/addressee',
1123 'addressee_custom' => [
1124 'name' => 'addressee_custom',
1125 'type' => CRM_Utils_Type
::T_STRING
,
1126 'title' => ts('Addressee Custom'),
1127 'description' => ts('Custom Addressee.'),
1129 'size' => CRM_Utils_Type
::HUGE
,
1131 'where' => 'civicrm_contact.addressee_custom',
1133 'table_name' => 'civicrm_contact',
1134 'entity' => 'Contact',
1135 'bao' => 'CRM_Contact_BAO_Contact',
1141 'addressee_display' => [
1142 'name' => 'addressee_display',
1143 'type' => CRM_Utils_Type
::T_STRING
,
1144 'title' => ts('Addressee'),
1145 'description' => ts('Cache Addressee.'),
1147 'size' => CRM_Utils_Type
::HUGE
,
1148 'where' => 'civicrm_contact.addressee_display',
1149 'table_name' => 'civicrm_contact',
1150 'entity' => 'Contact',
1151 'bao' => 'CRM_Contact_BAO_Contact',
1155 'name' => 'job_title',
1156 'type' => CRM_Utils_Type
::T_STRING
,
1157 'title' => ts('Job Title'),
1158 'description' => ts('Job Title'),
1162 'where' => 'civicrm_contact.job_title',
1163 'headerPattern' => '/^job|(j(ob\s)?title)$/i',
1164 'dataPattern' => '//',
1166 'contactType' => 'Individual',
1167 'table_name' => 'civicrm_contact',
1168 'entity' => 'Contact',
1169 'bao' => 'CRM_Contact_BAO_Contact',
1176 'name' => 'gender_id',
1177 'type' => CRM_Utils_Type
::T_INT
,
1178 'title' => ts('Gender'),
1179 'description' => ts('FK to gender ID'),
1181 'where' => 'civicrm_contact.gender_id',
1182 'headerPattern' => '/^gender$/i',
1184 'contactType' => 'Individual',
1185 'table_name' => 'civicrm_contact',
1186 'entity' => 'Contact',
1187 'bao' => 'CRM_Contact_BAO_Contact',
1192 'pseudoconstant' => [
1193 'optionGroupName' => 'gender',
1194 'optionEditPath' => 'civicrm/admin/options/gender',
1198 'name' => 'birth_date',
1199 'type' => CRM_Utils_Type
::T_DATE
,
1200 'title' => ts('Birth Date'),
1201 'description' => ts('Date of birth'),
1203 'where' => 'civicrm_contact.birth_date',
1204 'headerPattern' => '/^birth|(b(irth\s)?date)|D(\W*)O(\W*)B(\W*)$/i',
1205 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
1207 'contactType' => 'Individual',
1208 'table_name' => 'civicrm_contact',
1209 'entity' => 'Contact',
1210 'bao' => 'CRM_Contact_BAO_Contact',
1213 'type' => 'Select Date',
1214 'formatType' => 'birth',
1218 'name' => 'is_deceased',
1219 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1220 'title' => ts('Deceased'),
1223 'where' => 'civicrm_contact.is_deceased',
1224 'headerPattern' => '/i(s\s)?d(eceased)$/i',
1226 'contactType' => 'Individual',
1228 'table_name' => 'civicrm_contact',
1229 'entity' => 'Contact',
1230 'bao' => 'CRM_Contact_BAO_Contact',
1233 'type' => 'CheckBox',
1236 'deceased_date' => [
1237 'name' => 'deceased_date',
1238 'type' => CRM_Utils_Type
::T_DATE
,
1239 'title' => ts('Deceased Date'),
1240 'description' => ts('Date of deceased'),
1242 'where' => 'civicrm_contact.deceased_date',
1243 'headerPattern' => '/^deceased|(d(eceased\s)?date)$/i',
1245 'contactType' => 'Individual',
1246 'table_name' => 'civicrm_contact',
1247 'entity' => 'Contact',
1248 'bao' => 'CRM_Contact_BAO_Contact',
1251 'type' => 'Select Date',
1252 'formatType' => 'birth',
1255 'household_name' => [
1256 'name' => 'household_name',
1257 'type' => CRM_Utils_Type
::T_STRING
,
1258 'title' => ts('Household Name'),
1259 'description' => ts('Household Name.'),
1263 'where' => 'civicrm_contact.household_name',
1264 'headerPattern' => '/^household|(h(ousehold\s)?name)$/i',
1265 'dataPattern' => '/^\w+$/',
1267 'contactType' => 'Household',
1268 'table_name' => 'civicrm_contact',
1269 'entity' => 'Contact',
1270 'bao' => 'CRM_Contact_BAO_Contact',
1276 'primary_contact_id' => [
1277 'name' => 'primary_contact_id',
1278 'type' => CRM_Utils_Type
::T_INT
,
1279 'title' => ts('Household Primary Contact ID'),
1280 'description' => ts('Optional FK to Primary Contact for this household.'),
1281 'where' => 'civicrm_contact.primary_contact_id',
1282 'contactType' => 'Household',
1283 'table_name' => 'civicrm_contact',
1284 'entity' => 'Contact',
1285 'bao' => 'CRM_Contact_BAO_Contact',
1287 'FKClassName' => 'CRM_Contact_DAO_Contact',
1289 'organization_name' => [
1290 'name' => 'organization_name',
1291 'type' => CRM_Utils_Type
::T_STRING
,
1292 'title' => ts('Organization Name'),
1293 'description' => ts('Organization Name.'),
1297 'where' => 'civicrm_contact.organization_name',
1298 'headerPattern' => '/^organization|(o(rganization\s)?name)$/i',
1299 'dataPattern' => '/^\w+$/',
1301 'contactType' => 'Organization',
1302 'table_name' => 'civicrm_contact',
1303 'entity' => 'Contact',
1304 'bao' => 'CRM_Contact_BAO_Contact',
1311 'name' => 'sic_code',
1312 'type' => CRM_Utils_Type
::T_STRING
,
1313 'title' => ts('Sic Code'),
1314 'description' => ts('Standard Industry Classification Code.'),
1316 'size' => CRM_Utils_Type
::EIGHT
,
1318 'where' => 'civicrm_contact.sic_code',
1319 'headerPattern' => '/^sic|(s(ic\s)?code)$/i',
1321 'contactType' => 'Organization',
1322 'table_name' => 'civicrm_contact',
1323 'entity' => 'Contact',
1324 'bao' => 'CRM_Contact_BAO_Contact',
1330 'user_unique_id' => [
1331 'name' => 'user_unique_id',
1332 'type' => CRM_Utils_Type
::T_STRING
,
1333 'title' => ts('Unique ID (OpenID)'),
1334 'description' => ts('the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM'),
1336 'size' => CRM_Utils_Type
::HUGE
,
1338 'where' => 'civicrm_contact.user_unique_id',
1339 'headerPattern' => '/^Open\s?ID|u(niq\w*)?\s?ID/i',
1340 'dataPattern' => '/^[\w\/\:\.]+$/',
1343 'table_name' => 'civicrm_contact',
1344 'entity' => 'Contact',
1345 'bao' => 'CRM_Contact_BAO_Contact',
1351 'current_employer_id' => [
1352 'name' => 'employer_id',
1353 'type' => CRM_Utils_Type
::T_INT
,
1354 'title' => ts('Current Employer'),
1355 'description' => ts('OPTIONAL FK to civicrm_contact record.'),
1356 'where' => 'civicrm_contact.employer_id',
1358 'contactType' => 'Individual',
1359 'table_name' => 'civicrm_contact',
1360 'entity' => 'Contact',
1361 'bao' => 'CRM_Contact_BAO_Contact',
1363 'FKClassName' => 'CRM_Contact_DAO_Contact',
1365 'type' => 'EntityRef',
1368 'contact_is_deleted' => [
1369 'name' => 'is_deleted',
1370 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1371 'title' => ts('Contact is in Trash'),
1373 'where' => 'civicrm_contact.is_deleted',
1376 'table_name' => 'civicrm_contact',
1377 'entity' => 'Contact',
1378 'bao' => 'CRM_Contact_BAO_Contact',
1381 'type' => 'CheckBox',
1385 'name' => 'created_date',
1386 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1387 'title' => ts('Created Date'),
1388 'description' => ts('When was the contact was created.'),
1389 'required' => FALSE,
1390 'where' => 'civicrm_contact.created_date',
1392 'default' => 'NULL',
1393 'table_name' => 'civicrm_contact',
1394 'entity' => 'Contact',
1395 'bao' => 'CRM_Contact_BAO_Contact',
1398 'modified_date' => [
1399 'name' => 'modified_date',
1400 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1401 'title' => ts('Modified Date'),
1402 'description' => ts('When was the contact (or closely related entity) was created or modified or deleted.'),
1403 'required' => FALSE,
1404 'where' => 'civicrm_contact.modified_date',
1406 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
1407 'table_name' => 'civicrm_contact',
1408 'entity' => 'Contact',
1409 'bao' => 'CRM_Contact_BAO_Contact',
1413 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
1415 return Civi
::$statics[__CLASS__
]['fields'];
1419 * Return a mapping from field-name to the corresponding key (as used in fields()).
1422 * Array(string $name => string $uniqueName).
1424 public static function &fieldKeys() {
1425 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
1426 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
1428 return Civi
::$statics[__CLASS__
]['fieldKeys'];
1432 * Returns the names of this table
1436 public static function getTableName() {
1437 return self
::$_tableName;
1441 * Returns if this table needs to be logged
1445 public function getLog() {
1450 * Returns the list of fields that can be imported
1452 * @param bool $prefix
1456 public static function &import($prefix = FALSE) {
1457 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contact', $prefix, []);
1462 * Returns the list of fields that can be exported
1464 * @param bool $prefix
1468 public static function &export($prefix = FALSE) {
1469 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contact', $prefix, []);
1474 * Returns the list of indices
1476 * @param bool $localize
1480 public static function indices($localize = TRUE) {
1482 'index_contact_type' => [
1483 'name' => 'index_contact_type',
1485 0 => 'contact_type',
1487 'localizable' => FALSE,
1488 'sig' => 'civicrm_contact::0::contact_type',
1490 'index_contact_sub_type' => [
1491 'name' => 'index_contact_sub_type',
1493 0 => 'contact_sub_type',
1495 'localizable' => FALSE,
1496 'sig' => 'civicrm_contact::0::contact_sub_type',
1498 'UI_external_identifier' => [
1499 'name' => 'UI_external_identifier',
1501 0 => 'external_identifier',
1503 'localizable' => FALSE,
1505 'sig' => 'civicrm_contact::1::external_identifier',
1507 'index_sort_name' => [
1508 'name' => 'index_sort_name',
1512 'localizable' => FALSE,
1513 'sig' => 'civicrm_contact::0::sort_name',
1515 'index_preferred_communication_method' => [
1516 'name' => 'index_preferred_communication_method',
1518 0 => 'preferred_communication_method',
1520 'localizable' => FALSE,
1521 'sig' => 'civicrm_contact::0::preferred_communication_method',
1524 'name' => 'index_hash',
1528 'localizable' => FALSE,
1529 'sig' => 'civicrm_contact::0::hash',
1531 'index_api_key' => [
1532 'name' => 'index_api_key',
1536 'localizable' => FALSE,
1537 'sig' => 'civicrm_contact::0::api_key',
1539 'index_first_name' => [
1540 'name' => 'index_first_name',
1544 'localizable' => FALSE,
1545 'sig' => 'civicrm_contact::0::first_name',
1547 'index_last_name' => [
1548 'name' => 'index_last_name',
1552 'localizable' => FALSE,
1553 'sig' => 'civicrm_contact::0::last_name',
1556 'name' => 'UI_prefix',
1560 'localizable' => FALSE,
1561 'sig' => 'civicrm_contact::0::prefix_id',
1564 'name' => 'UI_suffix',
1568 'localizable' => FALSE,
1569 'sig' => 'civicrm_contact::0::suffix_id',
1571 'index_communication_style_id' => [
1572 'name' => 'index_communication_style_id',
1574 0 => 'communication_style_id',
1576 'localizable' => FALSE,
1577 'sig' => 'civicrm_contact::0::communication_style_id',
1580 'name' => 'UI_gender',
1584 'localizable' => FALSE,
1585 'sig' => 'civicrm_contact::0::gender_id',
1587 'index_is_deceased' => [
1588 'name' => 'index_is_deceased',
1592 'localizable' => FALSE,
1593 'sig' => 'civicrm_contact::0::is_deceased',
1595 'index_household_name' => [
1596 'name' => 'index_household_name',
1598 0 => 'household_name',
1600 'localizable' => FALSE,
1601 'sig' => 'civicrm_contact::0::household_name',
1603 'index_organization_name' => [
1604 'name' => 'index_organization_name',
1606 0 => 'organization_name',
1608 'localizable' => FALSE,
1609 'sig' => 'civicrm_contact::0::organization_name',
1611 'index_is_deleted_sort_name' => [
1612 'name' => 'index_is_deleted_sort_name',
1618 'localizable' => FALSE,
1619 'sig' => 'civicrm_contact::0::is_deleted::sort_name::id',
1621 'index_created_date' => [
1622 'name' => 'index_created_date',
1624 0 => 'created_date',
1626 'localizable' => FALSE,
1627 'sig' => 'civicrm_contact::0::created_date',
1629 'index_modified_date' => [
1630 'name' => 'index_modified_date',
1632 0 => 'modified_date',
1634 'localizable' => FALSE,
1635 'sig' => 'civicrm_contact::0::modified_date',
1638 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;