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:da59563e28c0229228f7c2baa20caabf)
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',
444 'name' => 'contact_type',
445 'type' => CRM_Utils_Type
::T_STRING
,
446 'title' => ts('Contact Type'),
447 'description' => ts('Type of Contact.'),
449 'size' => CRM_Utils_Type
::BIG
,
450 'where' => 'civicrm_contact.contact_type',
452 'contactType' => NULL,
453 'table_name' => 'civicrm_contact',
454 'entity' => 'Contact',
455 'bao' => 'CRM_Contact_BAO_Contact',
460 'pseudoconstant' => [
461 'table' => 'civicrm_contact_type',
462 'keyColumn' => 'name',
463 'labelColumn' => 'label',
464 'condition' => 'parent_id IS NULL',
468 'contact_sub_type' => [
469 'name' => 'contact_sub_type',
470 'type' => CRM_Utils_Type
::T_STRING
,
471 'title' => ts('Contact Subtype'),
472 'description' => ts('May be used to over-ride contact view and edit templates.'),
474 'size' => CRM_Utils_Type
::HUGE
,
476 'where' => 'civicrm_contact.contact_sub_type',
477 'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
479 'table_name' => 'civicrm_contact',
480 'entity' => 'Contact',
481 'bao' => 'CRM_Contact_BAO_Contact',
483 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
487 'pseudoconstant' => [
488 'table' => 'civicrm_contact_type',
489 'keyColumn' => 'name',
490 'labelColumn' => 'label',
491 'condition' => 'parent_id IS NOT NULL',
496 'name' => 'do_not_email',
497 'type' => CRM_Utils_Type
::T_BOOLEAN
,
498 'title' => ts('Do Not Email'),
500 'where' => 'civicrm_contact.do_not_email',
501 'headerPattern' => '/d(o )?(not )?(email)/i',
502 'dataPattern' => '/^\d{1,}$/',
505 'table_name' => 'civicrm_contact',
506 'entity' => 'Contact',
507 'bao' => 'CRM_Contact_BAO_Contact',
510 'type' => 'CheckBox',
515 'name' => 'do_not_phone',
516 'type' => CRM_Utils_Type
::T_BOOLEAN
,
517 'title' => ts('Do Not Phone'),
519 'where' => 'civicrm_contact.do_not_phone',
520 'headerPattern' => '/d(o )?(not )?(call|phone)/i',
521 'dataPattern' => '/^\d{1,}$/',
524 'table_name' => 'civicrm_contact',
525 'entity' => 'Contact',
526 'bao' => 'CRM_Contact_BAO_Contact',
529 'type' => 'CheckBox',
534 'name' => 'do_not_mail',
535 'type' => CRM_Utils_Type
::T_BOOLEAN
,
536 'title' => ts('Do Not Mail'),
538 'where' => 'civicrm_contact.do_not_mail',
539 'headerPattern' => '/^(d(o\s)?n(ot\s)?mail)|(\w*)?bulk\s?(\w*)$/i',
540 'dataPattern' => '/^\d{1,}$/',
543 'table_name' => 'civicrm_contact',
544 'entity' => 'Contact',
545 'bao' => 'CRM_Contact_BAO_Contact',
548 'type' => 'CheckBox',
553 'name' => 'do_not_sms',
554 'type' => CRM_Utils_Type
::T_BOOLEAN
,
555 'title' => ts('Do Not Sms'),
557 'where' => 'civicrm_contact.do_not_sms',
558 'headerPattern' => '/d(o )?(not )?(sms)/i',
559 'dataPattern' => '/^\d{1,}$/',
562 'table_name' => 'civicrm_contact',
563 'entity' => 'Contact',
564 'bao' => 'CRM_Contact_BAO_Contact',
567 'type' => 'CheckBox',
572 'name' => 'do_not_trade',
573 'type' => CRM_Utils_Type
::T_BOOLEAN
,
574 'title' => ts('Do Not Trade'),
576 'where' => 'civicrm_contact.do_not_trade',
577 'headerPattern' => '/d(o )?(not )?(trade)/i',
578 'dataPattern' => '/^\d{1,}$/',
581 'table_name' => 'civicrm_contact',
582 'entity' => 'Contact',
583 'bao' => 'CRM_Contact_BAO_Contact',
586 'type' => 'CheckBox',
591 'name' => 'is_opt_out',
592 'type' => CRM_Utils_Type
::T_BOOLEAN
,
593 'title' => ts('No Bulk Emails (User Opt Out)'),
594 'description' => ts('Has the contact opted out from receiving all bulk email from the organization or site domain?'),
597 'where' => 'civicrm_contact.is_opt_out',
600 'table_name' => 'civicrm_contact',
601 'entity' => 'Contact',
602 'bao' => 'CRM_Contact_BAO_Contact',
605 'type' => 'CheckBox',
609 'legal_identifier' => [
610 'name' => 'legal_identifier',
611 'type' => CRM_Utils_Type
::T_STRING
,
612 'title' => ts('Legal Identifier'),
613 'description' => ts('May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.'),
615 'size' => CRM_Utils_Type
::MEDIUM
,
617 'where' => 'civicrm_contact.legal_identifier',
618 'headerPattern' => '/legal\s?id/i',
619 'dataPattern' => '/\w+?\d{5,}/',
621 'table_name' => 'civicrm_contact',
622 'entity' => 'Contact',
623 'bao' => 'CRM_Contact_BAO_Contact',
630 'external_identifier' => [
631 'name' => 'external_identifier',
632 'type' => CRM_Utils_Type
::T_STRING
,
633 'title' => ts('External Identifier'),
634 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
638 'where' => 'civicrm_contact.external_identifier',
639 'headerPattern' => '/external\s?id/i',
640 'dataPattern' => '/^\d{11,}$/',
642 'table_name' => 'civicrm_contact',
643 'entity' => 'Contact',
644 'bao' => 'CRM_Contact_BAO_Contact',
652 'name' => 'sort_name',
653 'type' => CRM_Utils_Type
::T_STRING
,
654 'title' => ts('Sort Name'),
655 'description' => ts('Name used for sorting different contact types'),
658 'where' => 'civicrm_contact.sort_name',
660 'table_name' => 'civicrm_contact',
661 'entity' => 'Contact',
662 'bao' => 'CRM_Contact_BAO_Contact',
670 'name' => 'display_name',
671 'type' => CRM_Utils_Type
::T_STRING
,
672 'title' => ts('Display Name'),
673 'description' => ts('Formatted name representing preferred format for display/print/other output.'),
676 'where' => 'civicrm_contact.display_name',
678 'table_name' => 'civicrm_contact',
679 'entity' => 'Contact',
680 'bao' => 'CRM_Contact_BAO_Contact',
688 'name' => 'nick_name',
689 'type' => CRM_Utils_Type
::T_STRING
,
690 'title' => ts('Nickname'),
691 'description' => ts('Nickname.'),
695 'where' => 'civicrm_contact.nick_name',
696 'headerPattern' => '/n(ick\s)name|nick$/i',
697 'dataPattern' => '/^\w+$/',
699 'table_name' => 'civicrm_contact',
700 'entity' => 'Contact',
701 'bao' => 'CRM_Contact_BAO_Contact',
709 'name' => 'legal_name',
710 'type' => CRM_Utils_Type
::T_STRING
,
711 'title' => ts('Legal Name'),
712 'description' => ts('Legal Name.'),
716 'where' => 'civicrm_contact.legal_name',
717 'headerPattern' => '/^legal|(l(egal\s)?name)$/i',
719 'contactType' => 'Organization',
720 'table_name' => 'civicrm_contact',
721 'entity' => 'Contact',
722 'bao' => 'CRM_Contact_BAO_Contact',
730 'name' => 'image_URL',
731 'type' => CRM_Utils_Type
::T_TEXT
,
732 'title' => ts('Image Url'),
733 'description' => ts('optional URL for preferred image (photo, logo, etc.) to display for this contact.'),
735 'where' => 'civicrm_contact.image_URL',
737 'table_name' => 'civicrm_contact',
738 'entity' => 'Contact',
739 'bao' => 'CRM_Contact_BAO_Contact',
746 'preferred_communication_method' => [
747 'name' => 'preferred_communication_method',
748 'type' => CRM_Utils_Type
::T_STRING
,
749 'title' => ts('Preferred Communication Method'),
750 'description' => ts('What is the preferred mode of communication.'),
752 'size' => CRM_Utils_Type
::HUGE
,
754 'where' => 'civicrm_contact.preferred_communication_method',
755 'headerPattern' => '/^p(ref\w*\s)?c(omm\w*)|( meth\w*)$/i',
756 'dataPattern' => '/^\w+$/',
758 'table_name' => 'civicrm_contact',
759 'entity' => 'Contact',
760 'bao' => 'CRM_Contact_BAO_Contact',
762 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
766 'pseudoconstant' => [
767 'optionGroupName' => 'preferred_communication_method',
768 'optionEditPath' => 'civicrm/admin/options/preferred_communication_method',
772 'preferred_language' => [
773 'name' => 'preferred_language',
774 'type' => CRM_Utils_Type
::T_STRING
,
775 'title' => ts('Preferred Language'),
776 'description' => ts('Which language is preferred for communication. FK to languages in civicrm_option_value.'),
778 'size' => CRM_Utils_Type
::SIX
,
780 'where' => 'civicrm_contact.preferred_language',
781 'headerPattern' => '/^lang/i',
783 'table_name' => 'civicrm_contact',
784 'entity' => 'Contact',
785 'bao' => 'CRM_Contact_BAO_Contact',
790 'pseudoconstant' => [
791 'optionGroupName' => 'languages',
792 'keyColumn' => 'name',
793 'optionEditPath' => 'civicrm/admin/options/languages',
797 'preferred_mail_format' => [
798 'name' => 'preferred_mail_format',
799 'type' => CRM_Utils_Type
::T_STRING
,
800 'title' => ts('Preferred Mail Format'),
801 'description' => ts('What is the preferred mode of sending an email.'),
803 'size' => CRM_Utils_Type
::EIGHT
,
805 'where' => 'civicrm_contact.preferred_mail_format',
806 'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i',
809 'table_name' => 'civicrm_contact',
810 'entity' => 'Contact',
811 'bao' => 'CRM_Contact_BAO_Contact',
816 'pseudoconstant' => [
817 'callback' => 'CRM_Core_SelectValues::pmf',
823 'type' => CRM_Utils_Type
::T_STRING
,
824 'title' => ts('Contact Hash'),
825 'description' => ts('Key for validating requests related to this contact.'),
827 'size' => CRM_Utils_Type
::MEDIUM
,
828 'where' => 'civicrm_contact.hash',
830 'table_name' => 'civicrm_contact',
831 'entity' => 'Contact',
832 'bao' => 'CRM_Contact_BAO_Contact',
838 'type' => CRM_Utils_Type
::T_STRING
,
839 'title' => ts('Api Key'),
840 'description' => ts('API Key for validating requests related to this contact.'),
842 'size' => CRM_Utils_Type
::MEDIUM
,
843 'where' => 'civicrm_contact.api_key',
846 'administer CiviCRM',
850 'table_name' => 'civicrm_contact',
851 'entity' => 'Contact',
852 'bao' => 'CRM_Contact_BAO_Contact',
856 'contact_source' => [
858 'type' => CRM_Utils_Type
::T_STRING
,
859 'title' => ts('Contact Source'),
860 'description' => ts('where contact come from, e.g. import, donate module insert...'),
864 'where' => 'civicrm_contact.source',
865 'headerPattern' => '/(C(ontact\s)?Source)$/i',
867 'table_name' => 'civicrm_contact',
868 'entity' => 'Contact',
869 'bao' => 'CRM_Contact_BAO_Contact',
877 'name' => 'first_name',
878 'type' => CRM_Utils_Type
::T_STRING
,
879 'title' => ts('First Name'),
880 'description' => ts('First Name.'),
884 'where' => 'civicrm_contact.first_name',
885 'headerPattern' => '/^first|(f(irst\s)?name)$/i',
886 'dataPattern' => '/^\w+$/',
888 'contactType' => 'Individual',
889 'table_name' => 'civicrm_contact',
890 'entity' => 'Contact',
891 'bao' => 'CRM_Contact_BAO_Contact',
899 'name' => 'middle_name',
900 'type' => CRM_Utils_Type
::T_STRING
,
901 'title' => ts('Middle Name'),
902 'description' => ts('Middle Name.'),
906 'where' => 'civicrm_contact.middle_name',
907 'headerPattern' => '/^middle|(m(iddle\s)?name)$/i',
908 'dataPattern' => '/^\w+$/',
910 'contactType' => 'Individual',
911 'table_name' => 'civicrm_contact',
912 'entity' => 'Contact',
913 'bao' => 'CRM_Contact_BAO_Contact',
921 'name' => 'last_name',
922 'type' => CRM_Utils_Type
::T_STRING
,
923 'title' => ts('Last Name'),
924 'description' => ts('Last Name.'),
928 'where' => 'civicrm_contact.last_name',
929 'headerPattern' => '/^last|(l(ast\s)?name)$/i',
930 'dataPattern' => '/^\w+(\s\w+)?+$/',
932 'contactType' => 'Individual',
933 'table_name' => 'civicrm_contact',
934 'entity' => 'Contact',
935 'bao' => 'CRM_Contact_BAO_Contact',
943 'name' => 'prefix_id',
944 'type' => CRM_Utils_Type
::T_INT
,
945 'title' => ts('Individual Prefix'),
946 'description' => ts('Prefix or Title for name (Ms, Mr...). FK to prefix ID'),
948 'where' => 'civicrm_contact.prefix_id',
949 'headerPattern' => '/^(prefix|title)/i',
950 'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
952 'contactType' => 'Individual',
953 'table_name' => 'civicrm_contact',
954 'entity' => 'Contact',
955 'bao' => 'CRM_Contact_BAO_Contact',
960 'pseudoconstant' => [
961 'optionGroupName' => 'individual_prefix',
962 'optionEditPath' => 'civicrm/admin/options/individual_prefix',
967 'name' => 'suffix_id',
968 'type' => CRM_Utils_Type
::T_INT
,
969 'title' => ts('Individual Suffix'),
970 'description' => ts('Suffix for name (Jr, Sr...). FK to suffix ID'),
972 'where' => 'civicrm_contact.suffix_id',
973 'headerPattern' => '/^suffix$/i',
974 'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
976 'contactType' => 'Individual',
977 'table_name' => 'civicrm_contact',
978 'entity' => 'Contact',
979 'bao' => 'CRM_Contact_BAO_Contact',
984 'pseudoconstant' => [
985 'optionGroupName' => 'individual_suffix',
986 'optionEditPath' => 'civicrm/admin/options/individual_suffix',
991 'name' => 'formal_title',
992 'type' => CRM_Utils_Type
::T_STRING
,
993 'title' => ts('Formal Title'),
994 'description' => ts('Formal (academic or similar) title in front of name. (Prof., Dr. etc.)'),
996 'size' => CRM_Utils_Type
::BIG
,
998 'where' => 'civicrm_contact.formal_title',
999 'headerPattern' => '/^title/i',
1001 'contactType' => 'Individual',
1002 'table_name' => 'civicrm_contact',
1003 'entity' => 'Contact',
1004 'bao' => 'CRM_Contact_BAO_Contact',
1011 'communication_style_id' => [
1012 'name' => 'communication_style_id',
1013 'type' => CRM_Utils_Type
::T_INT
,
1014 'title' => ts('Communication Style'),
1015 'description' => ts('Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.'),
1017 'where' => 'civicrm_contact.communication_style_id',
1018 'headerPattern' => '/style/i',
1020 'table_name' => 'civicrm_contact',
1021 'entity' => 'Contact',
1022 'bao' => 'CRM_Contact_BAO_Contact',
1027 'pseudoconstant' => [
1028 'optionGroupName' => 'communication_style',
1029 'optionEditPath' => 'civicrm/admin/options/communication_style',
1033 'email_greeting_id' => [
1034 'name' => 'email_greeting_id',
1035 'type' => CRM_Utils_Type
::T_INT
,
1036 'title' => ts('Email Greeting ID'),
1037 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Email Greeting.'),
1038 'where' => 'civicrm_contact.email_greeting_id',
1040 'table_name' => 'civicrm_contact',
1041 'entity' => 'Contact',
1042 'bao' => 'CRM_Contact_BAO_Contact',
1047 'pseudoconstant' => [
1048 'optionGroupName' => 'email_greeting',
1049 'optionEditPath' => 'civicrm/admin/options/email_greeting',
1053 'email_greeting_custom' => [
1054 'name' => 'email_greeting_custom',
1055 'type' => CRM_Utils_Type
::T_STRING
,
1056 'title' => ts('Email Greeting Custom'),
1057 'description' => ts('Custom Email Greeting.'),
1059 'size' => CRM_Utils_Type
::HUGE
,
1061 'where' => 'civicrm_contact.email_greeting_custom',
1063 'table_name' => 'civicrm_contact',
1064 'entity' => 'Contact',
1065 'bao' => 'CRM_Contact_BAO_Contact',
1072 'email_greeting_display' => [
1073 'name' => 'email_greeting_display',
1074 'type' => CRM_Utils_Type
::T_STRING
,
1075 'title' => ts('Email Greeting'),
1076 'description' => ts('Cache Email Greeting.'),
1078 'size' => CRM_Utils_Type
::HUGE
,
1079 'where' => 'civicrm_contact.email_greeting_display',
1080 'table_name' => 'civicrm_contact',
1081 'entity' => 'Contact',
1082 'bao' => 'CRM_Contact_BAO_Contact',
1086 'postal_greeting_id' => [
1087 'name' => 'postal_greeting_id',
1088 'type' => CRM_Utils_Type
::T_INT
,
1089 'title' => ts('Postal Greeting ID'),
1090 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.'),
1091 'where' => 'civicrm_contact.postal_greeting_id',
1093 'table_name' => 'civicrm_contact',
1094 'entity' => 'Contact',
1095 'bao' => 'CRM_Contact_BAO_Contact',
1100 'pseudoconstant' => [
1101 'optionGroupName' => 'postal_greeting',
1102 'optionEditPath' => 'civicrm/admin/options/postal_greeting',
1106 'postal_greeting_custom' => [
1107 'name' => 'postal_greeting_custom',
1108 'type' => CRM_Utils_Type
::T_STRING
,
1109 'title' => ts('Postal Greeting Custom'),
1110 'description' => ts('Custom Postal greeting.'),
1112 'size' => CRM_Utils_Type
::HUGE
,
1114 'where' => 'civicrm_contact.postal_greeting_custom',
1116 'table_name' => 'civicrm_contact',
1117 'entity' => 'Contact',
1118 'bao' => 'CRM_Contact_BAO_Contact',
1125 'postal_greeting_display' => [
1126 'name' => 'postal_greeting_display',
1127 'type' => CRM_Utils_Type
::T_STRING
,
1128 'title' => ts('Postal Greeting'),
1129 'description' => ts('Cache Postal greeting.'),
1131 'size' => CRM_Utils_Type
::HUGE
,
1132 'where' => 'civicrm_contact.postal_greeting_display',
1133 'table_name' => 'civicrm_contact',
1134 'entity' => 'Contact',
1135 'bao' => 'CRM_Contact_BAO_Contact',
1140 'name' => 'addressee_id',
1141 'type' => CRM_Utils_Type
::T_INT
,
1142 'title' => ts('Addressee ID'),
1143 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Addressee.'),
1144 'where' => 'civicrm_contact.addressee_id',
1146 'table_name' => 'civicrm_contact',
1147 'entity' => 'Contact',
1148 'bao' => 'CRM_Contact_BAO_Contact',
1153 'pseudoconstant' => [
1154 'optionGroupName' => 'addressee',
1155 'optionEditPath' => 'civicrm/admin/options/addressee',
1159 'addressee_custom' => [
1160 'name' => 'addressee_custom',
1161 'type' => CRM_Utils_Type
::T_STRING
,
1162 'title' => ts('Addressee Custom'),
1163 'description' => ts('Custom Addressee.'),
1165 'size' => CRM_Utils_Type
::HUGE
,
1167 'where' => 'civicrm_contact.addressee_custom',
1169 'table_name' => 'civicrm_contact',
1170 'entity' => 'Contact',
1171 'bao' => 'CRM_Contact_BAO_Contact',
1178 'addressee_display' => [
1179 'name' => 'addressee_display',
1180 'type' => CRM_Utils_Type
::T_STRING
,
1181 'title' => ts('Addressee'),
1182 'description' => ts('Cache Addressee.'),
1184 'size' => CRM_Utils_Type
::HUGE
,
1185 'where' => 'civicrm_contact.addressee_display',
1186 'table_name' => 'civicrm_contact',
1187 'entity' => 'Contact',
1188 'bao' => 'CRM_Contact_BAO_Contact',
1193 'name' => 'job_title',
1194 'type' => CRM_Utils_Type
::T_STRING
,
1195 'title' => ts('Job Title'),
1196 'description' => ts('Job Title'),
1200 'where' => 'civicrm_contact.job_title',
1201 'headerPattern' => '/^job|(j(ob\s)?title)$/i',
1202 'dataPattern' => '//',
1204 'contactType' => 'Individual',
1205 'table_name' => 'civicrm_contact',
1206 'entity' => 'Contact',
1207 'bao' => 'CRM_Contact_BAO_Contact',
1215 'name' => 'gender_id',
1216 'type' => CRM_Utils_Type
::T_INT
,
1217 'title' => ts('Gender'),
1218 'description' => ts('FK to gender ID'),
1220 'where' => 'civicrm_contact.gender_id',
1221 'headerPattern' => '/^gender$/i',
1223 'contactType' => 'Individual',
1224 'table_name' => 'civicrm_contact',
1225 'entity' => 'Contact',
1226 'bao' => 'CRM_Contact_BAO_Contact',
1231 'pseudoconstant' => [
1232 'optionGroupName' => 'gender',
1233 'optionEditPath' => 'civicrm/admin/options/gender',
1238 'name' => 'birth_date',
1239 'type' => CRM_Utils_Type
::T_DATE
,
1240 'title' => ts('Birth Date'),
1241 'description' => ts('Date of birth'),
1243 'where' => 'civicrm_contact.birth_date',
1244 'headerPattern' => '/^birth|(b(irth\s)?date)|D(\W*)O(\W*)B(\W*)$/i',
1245 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
1247 'contactType' => 'Individual',
1248 'table_name' => 'civicrm_contact',
1249 'entity' => 'Contact',
1250 'bao' => 'CRM_Contact_BAO_Contact',
1253 'type' => 'Select Date',
1254 'formatType' => 'birth',
1259 'name' => 'is_deceased',
1260 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1261 'title' => ts('Deceased'),
1264 'where' => 'civicrm_contact.is_deceased',
1265 'headerPattern' => '/i(s\s)?d(eceased)$/i',
1267 'contactType' => 'Individual',
1269 'table_name' => 'civicrm_contact',
1270 'entity' => 'Contact',
1271 'bao' => 'CRM_Contact_BAO_Contact',
1274 'type' => 'CheckBox',
1278 'deceased_date' => [
1279 'name' => 'deceased_date',
1280 'type' => CRM_Utils_Type
::T_DATE
,
1281 'title' => ts('Deceased Date'),
1282 'description' => ts('Date of deceased'),
1284 'where' => 'civicrm_contact.deceased_date',
1285 'headerPattern' => '/^deceased|(d(eceased\s)?date)$/i',
1287 'contactType' => 'Individual',
1288 'table_name' => 'civicrm_contact',
1289 'entity' => 'Contact',
1290 'bao' => 'CRM_Contact_BAO_Contact',
1293 'type' => 'Select Date',
1294 'formatType' => 'birth',
1298 'household_name' => [
1299 'name' => 'household_name',
1300 'type' => CRM_Utils_Type
::T_STRING
,
1301 'title' => ts('Household Name'),
1302 'description' => ts('Household Name.'),
1306 'where' => 'civicrm_contact.household_name',
1307 'headerPattern' => '/^household|(h(ousehold\s)?name)$/i',
1308 'dataPattern' => '/^\w+$/',
1310 'contactType' => 'Household',
1311 'table_name' => 'civicrm_contact',
1312 'entity' => 'Contact',
1313 'bao' => 'CRM_Contact_BAO_Contact',
1320 'primary_contact_id' => [
1321 'name' => 'primary_contact_id',
1322 'type' => CRM_Utils_Type
::T_INT
,
1323 'title' => ts('Household Primary Contact ID'),
1324 'description' => ts('Optional FK to Primary Contact for this household.'),
1325 'where' => 'civicrm_contact.primary_contact_id',
1326 'contactType' => 'Household',
1327 'table_name' => 'civicrm_contact',
1328 'entity' => 'Contact',
1329 'bao' => 'CRM_Contact_BAO_Contact',
1331 'FKClassName' => 'CRM_Contact_DAO_Contact',
1334 'organization_name' => [
1335 'name' => 'organization_name',
1336 'type' => CRM_Utils_Type
::T_STRING
,
1337 'title' => ts('Organization Name'),
1338 'description' => ts('Organization Name.'),
1342 'where' => 'civicrm_contact.organization_name',
1343 'headerPattern' => '/^organization|(o(rganization\s)?name)$/i',
1344 'dataPattern' => '/^\w+$/',
1346 'contactType' => 'Organization',
1347 'table_name' => 'civicrm_contact',
1348 'entity' => 'Contact',
1349 'bao' => 'CRM_Contact_BAO_Contact',
1357 'name' => 'sic_code',
1358 'type' => CRM_Utils_Type
::T_STRING
,
1359 'title' => ts('Sic Code'),
1360 'description' => ts('Standard Industry Classification Code.'),
1362 'size' => CRM_Utils_Type
::EIGHT
,
1364 'where' => 'civicrm_contact.sic_code',
1365 'headerPattern' => '/^sic|(s(ic\s)?code)$/i',
1367 'contactType' => 'Organization',
1368 'table_name' => 'civicrm_contact',
1369 'entity' => 'Contact',
1370 'bao' => 'CRM_Contact_BAO_Contact',
1377 'user_unique_id' => [
1378 'name' => 'user_unique_id',
1379 'type' => CRM_Utils_Type
::T_STRING
,
1380 'title' => ts('Unique ID (OpenID)'),
1381 'description' => ts('the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM'),
1383 'size' => CRM_Utils_Type
::HUGE
,
1385 'where' => 'civicrm_contact.user_unique_id',
1386 'headerPattern' => '/^Open\s?ID|u(niq\w*)?\s?ID/i',
1387 'dataPattern' => '/^[\w\/\:\.]+$/',
1390 'table_name' => 'civicrm_contact',
1391 'entity' => 'Contact',
1392 'bao' => 'CRM_Contact_BAO_Contact',
1399 'current_employer_id' => [
1400 'name' => 'employer_id',
1401 'type' => CRM_Utils_Type
::T_INT
,
1402 'title' => ts('Current Employer'),
1403 'description' => ts('OPTIONAL FK to civicrm_contact record.'),
1404 'where' => 'civicrm_contact.employer_id',
1406 'contactType' => 'Individual',
1407 'table_name' => 'civicrm_contact',
1408 'entity' => 'Contact',
1409 'bao' => 'CRM_Contact_BAO_Contact',
1411 'FKClassName' => 'CRM_Contact_DAO_Contact',
1413 'type' => 'EntityRef',
1417 'contact_is_deleted' => [
1418 'name' => 'is_deleted',
1419 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1420 'title' => ts('Contact is in Trash'),
1422 'where' => 'civicrm_contact.is_deleted',
1425 'access deleted contacts',
1428 'table_name' => 'civicrm_contact',
1429 'entity' => 'Contact',
1430 'bao' => 'CRM_Contact_BAO_Contact',
1433 'type' => 'CheckBox',
1438 'name' => 'created_date',
1439 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1440 'title' => ts('Created Date'),
1441 'description' => ts('When was the contact was created.'),
1442 'required' => FALSE,
1443 'where' => 'civicrm_contact.created_date',
1445 'default' => 'NULL',
1446 'table_name' => 'civicrm_contact',
1447 'entity' => 'Contact',
1448 'bao' => 'CRM_Contact_BAO_Contact',
1452 'modified_date' => [
1453 'name' => 'modified_date',
1454 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1455 'title' => ts('Modified Date'),
1456 'description' => ts('When was the contact (or closely related entity) was created or modified or deleted.'),
1457 'required' => FALSE,
1458 'where' => 'civicrm_contact.modified_date',
1460 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
1461 'table_name' => 'civicrm_contact',
1462 'entity' => 'Contact',
1463 'bao' => 'CRM_Contact_BAO_Contact',
1468 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
1470 return Civi
::$statics[__CLASS__
]['fields'];
1474 * Return a mapping from field-name to the corresponding key (as used in fields()).
1477 * Array(string $name => string $uniqueName).
1479 public static function &fieldKeys() {
1480 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
1481 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
1483 return Civi
::$statics[__CLASS__
]['fieldKeys'];
1487 * Returns the names of this table
1491 public static function getTableName() {
1492 return self
::$_tableName;
1496 * Returns if this table needs to be logged
1500 public function getLog() {
1505 * Returns the list of fields that can be imported
1507 * @param bool $prefix
1511 public static function &import($prefix = FALSE) {
1512 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contact', $prefix, []);
1517 * Returns the list of fields that can be exported
1519 * @param bool $prefix
1523 public static function &export($prefix = FALSE) {
1524 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contact', $prefix, []);
1529 * Returns the list of indices
1531 * @param bool $localize
1535 public static function indices($localize = TRUE) {
1537 'index_contact_type' => [
1538 'name' => 'index_contact_type',
1540 0 => 'contact_type',
1542 'localizable' => FALSE,
1543 'sig' => 'civicrm_contact::0::contact_type',
1545 'index_contact_sub_type' => [
1546 'name' => 'index_contact_sub_type',
1548 0 => 'contact_sub_type',
1550 'localizable' => FALSE,
1551 'sig' => 'civicrm_contact::0::contact_sub_type',
1553 'UI_external_identifier' => [
1554 'name' => 'UI_external_identifier',
1556 0 => 'external_identifier',
1558 'localizable' => FALSE,
1560 'sig' => 'civicrm_contact::1::external_identifier',
1562 'index_sort_name' => [
1563 'name' => 'index_sort_name',
1567 'localizable' => FALSE,
1568 'sig' => 'civicrm_contact::0::sort_name',
1570 'index_preferred_communication_method' => [
1571 'name' => 'index_preferred_communication_method',
1573 0 => 'preferred_communication_method',
1575 'localizable' => FALSE,
1576 'sig' => 'civicrm_contact::0::preferred_communication_method',
1579 'name' => 'index_hash',
1583 'localizable' => FALSE,
1584 'sig' => 'civicrm_contact::0::hash',
1586 'index_api_key' => [
1587 'name' => 'index_api_key',
1591 'localizable' => FALSE,
1592 'sig' => 'civicrm_contact::0::api_key',
1594 'index_first_name' => [
1595 'name' => 'index_first_name',
1599 'localizable' => FALSE,
1600 'sig' => 'civicrm_contact::0::first_name',
1602 'index_last_name' => [
1603 'name' => 'index_last_name',
1607 'localizable' => FALSE,
1608 'sig' => 'civicrm_contact::0::last_name',
1611 'name' => 'UI_prefix',
1615 'localizable' => FALSE,
1616 'sig' => 'civicrm_contact::0::prefix_id',
1619 'name' => 'UI_suffix',
1623 'localizable' => FALSE,
1624 'sig' => 'civicrm_contact::0::suffix_id',
1626 'index_communication_style_id' => [
1627 'name' => 'index_communication_style_id',
1629 0 => 'communication_style_id',
1631 'localizable' => FALSE,
1632 'sig' => 'civicrm_contact::0::communication_style_id',
1635 'name' => 'UI_gender',
1639 'localizable' => FALSE,
1640 'sig' => 'civicrm_contact::0::gender_id',
1642 'index_is_deceased' => [
1643 'name' => 'index_is_deceased',
1647 'localizable' => FALSE,
1648 'sig' => 'civicrm_contact::0::is_deceased',
1650 'index_household_name' => [
1651 'name' => 'index_household_name',
1653 0 => 'household_name',
1655 'localizable' => FALSE,
1656 'sig' => 'civicrm_contact::0::household_name',
1658 'index_organization_name' => [
1659 'name' => 'index_organization_name',
1661 0 => 'organization_name',
1663 'localizable' => FALSE,
1664 'sig' => 'civicrm_contact::0::organization_name',
1666 'index_is_deleted_sort_name' => [
1667 'name' => 'index_is_deleted_sort_name',
1673 'localizable' => FALSE,
1674 'sig' => 'civicrm_contact::0::is_deleted::sort_name::id',
1676 'index_created_date' => [
1677 'name' => 'index_created_date',
1679 0 => 'created_date',
1681 'localizable' => FALSE,
1682 'sig' => 'civicrm_contact::0::created_date',
1684 'index_modified_date' => [
1685 'name' => 'index_modified_date',
1687 0 => 'modified_date',
1689 'localizable' => FALSE,
1690 'sig' => 'civicrm_contact::0::modified_date',
1693 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;