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:e811ca59eee757951e6e190a318f9749)
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 'contactType' => NULL,
438 'table_name' => 'civicrm_contact',
439 'entity' => 'Contact',
440 'bao' => 'CRM_Contact_BAO_Contact',
445 'pseudoconstant' => [
446 'table' => 'civicrm_contact_type',
447 'keyColumn' => 'name',
448 'labelColumn' => 'label',
449 'condition' => 'parent_id IS NULL',
452 'contact_sub_type' => [
453 'name' => 'contact_sub_type',
454 'type' => CRM_Utils_Type
::T_STRING
,
455 'title' => ts('Contact Subtype'),
456 'description' => ts('May be used to over-ride contact view and edit templates.'),
458 'size' => CRM_Utils_Type
::HUGE
,
460 'where' => 'civicrm_contact.contact_sub_type',
461 'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
463 'table_name' => 'civicrm_contact',
464 'entity' => 'Contact',
465 'bao' => 'CRM_Contact_BAO_Contact',
467 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
471 'pseudoconstant' => [
472 'table' => 'civicrm_contact_type',
473 'keyColumn' => 'name',
474 'labelColumn' => 'label',
475 'condition' => 'parent_id IS NOT NULL',
479 'name' => 'do_not_email',
480 'type' => CRM_Utils_Type
::T_BOOLEAN
,
481 'title' => ts('Do Not Email'),
483 'where' => 'civicrm_contact.do_not_email',
484 'headerPattern' => '/d(o )?(not )?(email)/i',
485 'dataPattern' => '/^\d{1,}$/',
488 'table_name' => 'civicrm_contact',
489 'entity' => 'Contact',
490 'bao' => 'CRM_Contact_BAO_Contact',
493 'type' => 'CheckBox',
497 'name' => 'do_not_phone',
498 'type' => CRM_Utils_Type
::T_BOOLEAN
,
499 'title' => ts('Do Not Phone'),
501 'where' => 'civicrm_contact.do_not_phone',
502 'headerPattern' => '/d(o )?(not )?(call|phone)/i',
503 'dataPattern' => '/^\d{1,}$/',
506 'table_name' => 'civicrm_contact',
507 'entity' => 'Contact',
508 'bao' => 'CRM_Contact_BAO_Contact',
511 'type' => 'CheckBox',
515 'name' => 'do_not_mail',
516 'type' => CRM_Utils_Type
::T_BOOLEAN
,
517 'title' => ts('Do Not Mail'),
519 'where' => 'civicrm_contact.do_not_mail',
520 'headerPattern' => '/^(d(o\s)?n(ot\s)?mail)|(\w*)?bulk\s?(\w*)$/i',
521 'dataPattern' => '/^\d{1,}$/',
524 'table_name' => 'civicrm_contact',
525 'entity' => 'Contact',
526 'bao' => 'CRM_Contact_BAO_Contact',
529 'type' => 'CheckBox',
533 'name' => 'do_not_sms',
534 'type' => CRM_Utils_Type
::T_BOOLEAN
,
535 'title' => ts('Do Not Sms'),
537 'where' => 'civicrm_contact.do_not_sms',
538 'headerPattern' => '/d(o )?(not )?(sms)/i',
539 'dataPattern' => '/^\d{1,}$/',
542 'table_name' => 'civicrm_contact',
543 'entity' => 'Contact',
544 'bao' => 'CRM_Contact_BAO_Contact',
547 'type' => 'CheckBox',
551 'name' => 'do_not_trade',
552 'type' => CRM_Utils_Type
::T_BOOLEAN
,
553 'title' => ts('Do Not Trade'),
555 'where' => 'civicrm_contact.do_not_trade',
556 'headerPattern' => '/d(o )?(not )?(trade)/i',
557 'dataPattern' => '/^\d{1,}$/',
560 'table_name' => 'civicrm_contact',
561 'entity' => 'Contact',
562 'bao' => 'CRM_Contact_BAO_Contact',
565 'type' => 'CheckBox',
569 'name' => 'is_opt_out',
570 'type' => CRM_Utils_Type
::T_BOOLEAN
,
571 'title' => ts('No Bulk Emails (User Opt Out)'),
572 'description' => ts('Has the contact opted out from receiving all bulk email from the organization or site domain?'),
575 'where' => 'civicrm_contact.is_opt_out',
578 'table_name' => 'civicrm_contact',
579 'entity' => 'Contact',
580 'bao' => 'CRM_Contact_BAO_Contact',
583 'type' => 'CheckBox',
586 'legal_identifier' => [
587 'name' => 'legal_identifier',
588 'type' => CRM_Utils_Type
::T_STRING
,
589 'title' => ts('Legal Identifier'),
590 'description' => ts('May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.'),
592 'size' => CRM_Utils_Type
::MEDIUM
,
594 'where' => 'civicrm_contact.legal_identifier',
595 'headerPattern' => '/legal\s?id/i',
596 'dataPattern' => '/\w+?\d{5,}/',
598 'table_name' => 'civicrm_contact',
599 'entity' => 'Contact',
600 'bao' => 'CRM_Contact_BAO_Contact',
606 'external_identifier' => [
607 'name' => 'external_identifier',
608 'type' => CRM_Utils_Type
::T_STRING
,
609 'title' => ts('External Identifier'),
610 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
614 'where' => 'civicrm_contact.external_identifier',
615 'headerPattern' => '/external\s?id/i',
616 'dataPattern' => '/^\d{11,}$/',
618 'table_name' => 'civicrm_contact',
619 'entity' => 'Contact',
620 'bao' => 'CRM_Contact_BAO_Contact',
627 'name' => 'sort_name',
628 'type' => CRM_Utils_Type
::T_STRING
,
629 'title' => ts('Sort Name'),
630 'description' => ts('Name used for sorting different contact types'),
633 'where' => 'civicrm_contact.sort_name',
635 'table_name' => 'civicrm_contact',
636 'entity' => 'Contact',
637 'bao' => 'CRM_Contact_BAO_Contact',
644 'name' => 'display_name',
645 'type' => CRM_Utils_Type
::T_STRING
,
646 'title' => ts('Display Name'),
647 'description' => ts('Formatted name representing preferred format for display/print/other output.'),
650 'where' => 'civicrm_contact.display_name',
652 'table_name' => 'civicrm_contact',
653 'entity' => 'Contact',
654 'bao' => 'CRM_Contact_BAO_Contact',
661 'name' => 'nick_name',
662 'type' => CRM_Utils_Type
::T_STRING
,
663 'title' => ts('Nickname'),
664 'description' => ts('Nickname.'),
668 'where' => 'civicrm_contact.nick_name',
669 'headerPattern' => '/n(ick\s)name|nick$/i',
670 'dataPattern' => '/^\w+$/',
672 'table_name' => 'civicrm_contact',
673 'entity' => 'Contact',
674 'bao' => 'CRM_Contact_BAO_Contact',
681 'name' => 'legal_name',
682 'type' => CRM_Utils_Type
::T_STRING
,
683 'title' => ts('Legal Name'),
684 'description' => ts('Legal Name.'),
688 'where' => 'civicrm_contact.legal_name',
689 'headerPattern' => '/^legal|(l(egal\s)?name)$/i',
691 'contactType' => 'Organization',
692 'table_name' => 'civicrm_contact',
693 'entity' => 'Contact',
694 'bao' => 'CRM_Contact_BAO_Contact',
701 'name' => 'image_URL',
702 'type' => CRM_Utils_Type
::T_TEXT
,
703 'title' => ts('Image Url'),
704 'description' => ts('optional URL for preferred image (photo, logo, etc.) to display for this contact.'),
706 'where' => 'civicrm_contact.image_URL',
708 'table_name' => 'civicrm_contact',
709 'entity' => 'Contact',
710 'bao' => 'CRM_Contact_BAO_Contact',
716 'preferred_communication_method' => [
717 'name' => 'preferred_communication_method',
718 'type' => CRM_Utils_Type
::T_STRING
,
719 'title' => ts('Preferred Communication Method'),
720 'description' => ts('What is the preferred mode of communication.'),
722 'size' => CRM_Utils_Type
::HUGE
,
724 'where' => 'civicrm_contact.preferred_communication_method',
725 'headerPattern' => '/^p(ref\w*\s)?c(omm\w*)|( meth\w*)$/i',
726 'dataPattern' => '/^\w+$/',
728 'table_name' => 'civicrm_contact',
729 'entity' => 'Contact',
730 'bao' => 'CRM_Contact_BAO_Contact',
732 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
736 'pseudoconstant' => [
737 'optionGroupName' => 'preferred_communication_method',
738 'optionEditPath' => 'civicrm/admin/options/preferred_communication_method',
741 'preferred_language' => [
742 'name' => 'preferred_language',
743 'type' => CRM_Utils_Type
::T_STRING
,
744 'title' => ts('Preferred Language'),
745 'description' => ts('Which language is preferred for communication. FK to languages in civicrm_option_value.'),
747 'size' => CRM_Utils_Type
::SIX
,
749 'where' => 'civicrm_contact.preferred_language',
750 'headerPattern' => '/^lang/i',
752 'table_name' => 'civicrm_contact',
753 'entity' => 'Contact',
754 'bao' => 'CRM_Contact_BAO_Contact',
759 'pseudoconstant' => [
760 'optionGroupName' => 'languages',
761 'keyColumn' => 'name',
762 'optionEditPath' => 'civicrm/admin/options/languages',
765 'preferred_mail_format' => [
766 'name' => 'preferred_mail_format',
767 'type' => CRM_Utils_Type
::T_STRING
,
768 'title' => ts('Preferred Mail Format'),
769 'description' => ts('What is the preferred mode of sending an email.'),
771 'size' => CRM_Utils_Type
::EIGHT
,
773 'where' => 'civicrm_contact.preferred_mail_format',
774 'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i',
777 'table_name' => 'civicrm_contact',
778 'entity' => 'Contact',
779 'bao' => 'CRM_Contact_BAO_Contact',
784 'pseudoconstant' => [
785 'callback' => 'CRM_Core_SelectValues::pmf',
790 'type' => CRM_Utils_Type
::T_STRING
,
791 'title' => ts('Contact Hash'),
792 'description' => ts('Key for validating requests related to this contact.'),
794 'size' => CRM_Utils_Type
::MEDIUM
,
795 'where' => 'civicrm_contact.hash',
797 'table_name' => 'civicrm_contact',
798 'entity' => 'Contact',
799 'bao' => 'CRM_Contact_BAO_Contact',
804 'type' => CRM_Utils_Type
::T_STRING
,
805 'title' => ts('Api Key'),
806 'description' => ts('API Key for validating requests related to this contact.'),
808 'size' => CRM_Utils_Type
::MEDIUM
,
809 'where' => 'civicrm_contact.api_key',
812 'administer CiviCRM',
816 'table_name' => 'civicrm_contact',
817 'entity' => 'Contact',
818 'bao' => 'CRM_Contact_BAO_Contact',
821 'contact_source' => [
823 'type' => CRM_Utils_Type
::T_STRING
,
824 'title' => ts('Contact Source'),
825 'description' => ts('where contact come from, e.g. import, donate module insert...'),
829 'where' => 'civicrm_contact.source',
830 'headerPattern' => '/(C(ontact\s)?Source)$/i',
832 'table_name' => 'civicrm_contact',
833 'entity' => 'Contact',
834 'bao' => 'CRM_Contact_BAO_Contact',
841 'name' => 'first_name',
842 'type' => CRM_Utils_Type
::T_STRING
,
843 'title' => ts('First Name'),
844 'description' => ts('First Name.'),
848 'where' => 'civicrm_contact.first_name',
849 'headerPattern' => '/^first|(f(irst\s)?name)$/i',
850 'dataPattern' => '/^\w+$/',
852 'contactType' => 'Individual',
853 'table_name' => 'civicrm_contact',
854 'entity' => 'Contact',
855 'bao' => 'CRM_Contact_BAO_Contact',
862 'name' => 'middle_name',
863 'type' => CRM_Utils_Type
::T_STRING
,
864 'title' => ts('Middle Name'),
865 'description' => ts('Middle Name.'),
869 'where' => 'civicrm_contact.middle_name',
870 'headerPattern' => '/^middle|(m(iddle\s)?name)$/i',
871 'dataPattern' => '/^\w+$/',
873 'contactType' => 'Individual',
874 'table_name' => 'civicrm_contact',
875 'entity' => 'Contact',
876 'bao' => 'CRM_Contact_BAO_Contact',
883 'name' => 'last_name',
884 'type' => CRM_Utils_Type
::T_STRING
,
885 'title' => ts('Last Name'),
886 'description' => ts('Last Name.'),
890 'where' => 'civicrm_contact.last_name',
891 'headerPattern' => '/^last|(l(ast\s)?name)$/i',
892 'dataPattern' => '/^\w+(\s\w+)?+$/',
894 'contactType' => 'Individual',
895 'table_name' => 'civicrm_contact',
896 'entity' => 'Contact',
897 'bao' => 'CRM_Contact_BAO_Contact',
904 'name' => 'prefix_id',
905 'type' => CRM_Utils_Type
::T_INT
,
906 'title' => ts('Individual Prefix'),
907 'description' => ts('Prefix or Title for name (Ms, Mr...). FK to prefix ID'),
909 'where' => 'civicrm_contact.prefix_id',
910 'headerPattern' => '/^(prefix|title)/i',
911 'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
913 'contactType' => 'Individual',
914 'table_name' => 'civicrm_contact',
915 'entity' => 'Contact',
916 'bao' => 'CRM_Contact_BAO_Contact',
921 'pseudoconstant' => [
922 'optionGroupName' => 'individual_prefix',
923 'optionEditPath' => 'civicrm/admin/options/individual_prefix',
927 'name' => 'suffix_id',
928 'type' => CRM_Utils_Type
::T_INT
,
929 'title' => ts('Individual Suffix'),
930 'description' => ts('Suffix for name (Jr, Sr...). FK to suffix ID'),
932 'where' => 'civicrm_contact.suffix_id',
933 'headerPattern' => '/^suffix$/i',
934 'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
936 'contactType' => 'Individual',
937 'table_name' => 'civicrm_contact',
938 'entity' => 'Contact',
939 'bao' => 'CRM_Contact_BAO_Contact',
944 'pseudoconstant' => [
945 'optionGroupName' => 'individual_suffix',
946 'optionEditPath' => 'civicrm/admin/options/individual_suffix',
950 'name' => 'formal_title',
951 'type' => CRM_Utils_Type
::T_STRING
,
952 'title' => ts('Formal Title'),
953 'description' => ts('Formal (academic or similar) title in front of name. (Prof., Dr. etc.)'),
955 'size' => CRM_Utils_Type
::BIG
,
957 'where' => 'civicrm_contact.formal_title',
958 'headerPattern' => '/^title/i',
960 'contactType' => 'Individual',
961 'table_name' => 'civicrm_contact',
962 'entity' => 'Contact',
963 'bao' => 'CRM_Contact_BAO_Contact',
969 'communication_style_id' => [
970 'name' => 'communication_style_id',
971 'type' => CRM_Utils_Type
::T_INT
,
972 'title' => ts('Communication Style'),
973 'description' => ts('Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.'),
975 'where' => 'civicrm_contact.communication_style_id',
976 'headerPattern' => '/style/i',
978 'table_name' => 'civicrm_contact',
979 'entity' => 'Contact',
980 'bao' => 'CRM_Contact_BAO_Contact',
985 'pseudoconstant' => [
986 'optionGroupName' => 'communication_style',
987 'optionEditPath' => 'civicrm/admin/options/communication_style',
990 'email_greeting_id' => [
991 'name' => 'email_greeting_id',
992 'type' => CRM_Utils_Type
::T_INT
,
993 'title' => ts('Email Greeting ID'),
994 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Email Greeting.'),
995 'where' => 'civicrm_contact.email_greeting_id',
997 'table_name' => 'civicrm_contact',
998 'entity' => 'Contact',
999 'bao' => 'CRM_Contact_BAO_Contact',
1004 'pseudoconstant' => [
1005 'optionGroupName' => 'email_greeting',
1006 'optionEditPath' => 'civicrm/admin/options/email_greeting',
1009 'email_greeting_custom' => [
1010 'name' => 'email_greeting_custom',
1011 'type' => CRM_Utils_Type
::T_STRING
,
1012 'title' => ts('Email Greeting Custom'),
1013 'description' => ts('Custom Email Greeting.'),
1015 'size' => CRM_Utils_Type
::HUGE
,
1017 'where' => 'civicrm_contact.email_greeting_custom',
1019 'table_name' => 'civicrm_contact',
1020 'entity' => 'Contact',
1021 'bao' => 'CRM_Contact_BAO_Contact',
1027 'email_greeting_display' => [
1028 'name' => 'email_greeting_display',
1029 'type' => CRM_Utils_Type
::T_STRING
,
1030 'title' => ts('Email Greeting'),
1031 'description' => ts('Cache Email Greeting.'),
1033 'size' => CRM_Utils_Type
::HUGE
,
1034 'where' => 'civicrm_contact.email_greeting_display',
1035 'table_name' => 'civicrm_contact',
1036 'entity' => 'Contact',
1037 'bao' => 'CRM_Contact_BAO_Contact',
1040 'postal_greeting_id' => [
1041 'name' => 'postal_greeting_id',
1042 'type' => CRM_Utils_Type
::T_INT
,
1043 'title' => ts('Postal Greeting ID'),
1044 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.'),
1045 'where' => 'civicrm_contact.postal_greeting_id',
1047 'table_name' => 'civicrm_contact',
1048 'entity' => 'Contact',
1049 'bao' => 'CRM_Contact_BAO_Contact',
1054 'pseudoconstant' => [
1055 'optionGroupName' => 'postal_greeting',
1056 'optionEditPath' => 'civicrm/admin/options/postal_greeting',
1059 'postal_greeting_custom' => [
1060 'name' => 'postal_greeting_custom',
1061 'type' => CRM_Utils_Type
::T_STRING
,
1062 'title' => ts('Postal Greeting Custom'),
1063 'description' => ts('Custom Postal greeting.'),
1065 'size' => CRM_Utils_Type
::HUGE
,
1067 'where' => 'civicrm_contact.postal_greeting_custom',
1069 'table_name' => 'civicrm_contact',
1070 'entity' => 'Contact',
1071 'bao' => 'CRM_Contact_BAO_Contact',
1077 'postal_greeting_display' => [
1078 'name' => 'postal_greeting_display',
1079 'type' => CRM_Utils_Type
::T_STRING
,
1080 'title' => ts('Postal Greeting'),
1081 'description' => ts('Cache Postal greeting.'),
1083 'size' => CRM_Utils_Type
::HUGE
,
1084 'where' => 'civicrm_contact.postal_greeting_display',
1085 'table_name' => 'civicrm_contact',
1086 'entity' => 'Contact',
1087 'bao' => 'CRM_Contact_BAO_Contact',
1091 'name' => 'addressee_id',
1092 'type' => CRM_Utils_Type
::T_INT
,
1093 'title' => ts('Addressee ID'),
1094 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Addressee.'),
1095 'where' => 'civicrm_contact.addressee_id',
1097 'table_name' => 'civicrm_contact',
1098 'entity' => 'Contact',
1099 'bao' => 'CRM_Contact_BAO_Contact',
1104 'pseudoconstant' => [
1105 'optionGroupName' => 'addressee',
1106 'optionEditPath' => 'civicrm/admin/options/addressee',
1109 'addressee_custom' => [
1110 'name' => 'addressee_custom',
1111 'type' => CRM_Utils_Type
::T_STRING
,
1112 'title' => ts('Addressee Custom'),
1113 'description' => ts('Custom Addressee.'),
1115 'size' => CRM_Utils_Type
::HUGE
,
1117 'where' => 'civicrm_contact.addressee_custom',
1119 'table_name' => 'civicrm_contact',
1120 'entity' => 'Contact',
1121 'bao' => 'CRM_Contact_BAO_Contact',
1127 'addressee_display' => [
1128 'name' => 'addressee_display',
1129 'type' => CRM_Utils_Type
::T_STRING
,
1130 'title' => ts('Addressee'),
1131 'description' => ts('Cache Addressee.'),
1133 'size' => CRM_Utils_Type
::HUGE
,
1134 'where' => 'civicrm_contact.addressee_display',
1135 'table_name' => 'civicrm_contact',
1136 'entity' => 'Contact',
1137 'bao' => 'CRM_Contact_BAO_Contact',
1141 'name' => 'job_title',
1142 'type' => CRM_Utils_Type
::T_STRING
,
1143 'title' => ts('Job Title'),
1144 'description' => ts('Job Title'),
1148 'where' => 'civicrm_contact.job_title',
1149 'headerPattern' => '/^job|(j(ob\s)?title)$/i',
1150 'dataPattern' => '//',
1152 'contactType' => 'Individual',
1153 'table_name' => 'civicrm_contact',
1154 'entity' => 'Contact',
1155 'bao' => 'CRM_Contact_BAO_Contact',
1162 'name' => 'gender_id',
1163 'type' => CRM_Utils_Type
::T_INT
,
1164 'title' => ts('Gender'),
1165 'description' => ts('FK to gender ID'),
1167 'where' => 'civicrm_contact.gender_id',
1168 'headerPattern' => '/^gender$/i',
1170 'contactType' => 'Individual',
1171 'table_name' => 'civicrm_contact',
1172 'entity' => 'Contact',
1173 'bao' => 'CRM_Contact_BAO_Contact',
1178 'pseudoconstant' => [
1179 'optionGroupName' => 'gender',
1180 'optionEditPath' => 'civicrm/admin/options/gender',
1184 'name' => 'birth_date',
1185 'type' => CRM_Utils_Type
::T_DATE
,
1186 'title' => ts('Birth Date'),
1187 'description' => ts('Date of birth'),
1189 'where' => 'civicrm_contact.birth_date',
1190 'headerPattern' => '/^birth|(b(irth\s)?date)|D(\W*)O(\W*)B(\W*)$/i',
1191 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
1193 'contactType' => 'Individual',
1194 'table_name' => 'civicrm_contact',
1195 'entity' => 'Contact',
1196 'bao' => 'CRM_Contact_BAO_Contact',
1199 'type' => 'Select Date',
1200 'formatType' => 'birth',
1204 'name' => 'is_deceased',
1205 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1206 'title' => ts('Deceased'),
1209 'where' => 'civicrm_contact.is_deceased',
1210 'headerPattern' => '/i(s\s)?d(eceased)$/i',
1212 'contactType' => 'Individual',
1214 'table_name' => 'civicrm_contact',
1215 'entity' => 'Contact',
1216 'bao' => 'CRM_Contact_BAO_Contact',
1219 'type' => 'CheckBox',
1222 'deceased_date' => [
1223 'name' => 'deceased_date',
1224 'type' => CRM_Utils_Type
::T_DATE
,
1225 'title' => ts('Deceased Date'),
1226 'description' => ts('Date of deceased'),
1228 'where' => 'civicrm_contact.deceased_date',
1229 'headerPattern' => '/^deceased|(d(eceased\s)?date)$/i',
1231 'contactType' => 'Individual',
1232 'table_name' => 'civicrm_contact',
1233 'entity' => 'Contact',
1234 'bao' => 'CRM_Contact_BAO_Contact',
1237 'type' => 'Select Date',
1238 'formatType' => 'birth',
1241 'household_name' => [
1242 'name' => 'household_name',
1243 'type' => CRM_Utils_Type
::T_STRING
,
1244 'title' => ts('Household Name'),
1245 'description' => ts('Household Name.'),
1249 'where' => 'civicrm_contact.household_name',
1250 'headerPattern' => '/^household|(h(ousehold\s)?name)$/i',
1251 'dataPattern' => '/^\w+$/',
1253 'contactType' => 'Household',
1254 'table_name' => 'civicrm_contact',
1255 'entity' => 'Contact',
1256 'bao' => 'CRM_Contact_BAO_Contact',
1262 'primary_contact_id' => [
1263 'name' => 'primary_contact_id',
1264 'type' => CRM_Utils_Type
::T_INT
,
1265 'title' => ts('Household Primary Contact ID'),
1266 'description' => ts('Optional FK to Primary Contact for this household.'),
1267 'where' => 'civicrm_contact.primary_contact_id',
1268 'contactType' => 'Household',
1269 'table_name' => 'civicrm_contact',
1270 'entity' => 'Contact',
1271 'bao' => 'CRM_Contact_BAO_Contact',
1273 'FKClassName' => 'CRM_Contact_DAO_Contact',
1275 'organization_name' => [
1276 'name' => 'organization_name',
1277 'type' => CRM_Utils_Type
::T_STRING
,
1278 'title' => ts('Organization Name'),
1279 'description' => ts('Organization Name.'),
1283 'where' => 'civicrm_contact.organization_name',
1284 'headerPattern' => '/^organization|(o(rganization\s)?name)$/i',
1285 'dataPattern' => '/^\w+$/',
1287 'contactType' => 'Organization',
1288 'table_name' => 'civicrm_contact',
1289 'entity' => 'Contact',
1290 'bao' => 'CRM_Contact_BAO_Contact',
1297 'name' => 'sic_code',
1298 'type' => CRM_Utils_Type
::T_STRING
,
1299 'title' => ts('Sic Code'),
1300 'description' => ts('Standard Industry Classification Code.'),
1302 'size' => CRM_Utils_Type
::EIGHT
,
1304 'where' => 'civicrm_contact.sic_code',
1305 'headerPattern' => '/^sic|(s(ic\s)?code)$/i',
1307 'contactType' => 'Organization',
1308 'table_name' => 'civicrm_contact',
1309 'entity' => 'Contact',
1310 'bao' => 'CRM_Contact_BAO_Contact',
1316 'user_unique_id' => [
1317 'name' => 'user_unique_id',
1318 'type' => CRM_Utils_Type
::T_STRING
,
1319 'title' => ts('Unique ID (OpenID)'),
1320 'description' => ts('the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM'),
1322 'size' => CRM_Utils_Type
::HUGE
,
1324 'where' => 'civicrm_contact.user_unique_id',
1325 'headerPattern' => '/^Open\s?ID|u(niq\w*)?\s?ID/i',
1326 'dataPattern' => '/^[\w\/\:\.]+$/',
1329 'table_name' => 'civicrm_contact',
1330 'entity' => 'Contact',
1331 'bao' => 'CRM_Contact_BAO_Contact',
1337 'current_employer_id' => [
1338 'name' => 'employer_id',
1339 'type' => CRM_Utils_Type
::T_INT
,
1340 'title' => ts('Current Employer'),
1341 'description' => ts('OPTIONAL FK to civicrm_contact record.'),
1342 'where' => 'civicrm_contact.employer_id',
1344 'contactType' => 'Individual',
1345 'table_name' => 'civicrm_contact',
1346 'entity' => 'Contact',
1347 'bao' => 'CRM_Contact_BAO_Contact',
1349 'FKClassName' => 'CRM_Contact_DAO_Contact',
1351 'type' => 'EntityRef',
1354 'contact_is_deleted' => [
1355 'name' => 'is_deleted',
1356 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1357 'title' => ts('Contact is in Trash'),
1359 'where' => 'civicrm_contact.is_deleted',
1362 'table_name' => 'civicrm_contact',
1363 'entity' => 'Contact',
1364 'bao' => 'CRM_Contact_BAO_Contact',
1367 'type' => 'CheckBox',
1371 'name' => 'created_date',
1372 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1373 'title' => ts('Created Date'),
1374 'description' => ts('When was the contact was created.'),
1375 'required' => FALSE,
1376 'where' => 'civicrm_contact.created_date',
1378 'default' => 'NULL',
1379 'table_name' => 'civicrm_contact',
1380 'entity' => 'Contact',
1381 'bao' => 'CRM_Contact_BAO_Contact',
1384 'modified_date' => [
1385 'name' => 'modified_date',
1386 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1387 'title' => ts('Modified Date'),
1388 'description' => ts('When was the contact (or closely related entity) was created or modified or deleted.'),
1389 'required' => FALSE,
1390 'where' => 'civicrm_contact.modified_date',
1392 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
1393 'table_name' => 'civicrm_contact',
1394 'entity' => 'Contact',
1395 'bao' => 'CRM_Contact_BAO_Contact',
1399 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
1401 return Civi
::$statics[__CLASS__
]['fields'];
1405 * Return a mapping from field-name to the corresponding key (as used in fields()).
1408 * Array(string $name => string $uniqueName).
1410 public static function &fieldKeys() {
1411 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
1412 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
1414 return Civi
::$statics[__CLASS__
]['fieldKeys'];
1418 * Returns the names of this table
1422 public static function getTableName() {
1423 return self
::$_tableName;
1427 * Returns if this table needs to be logged
1431 public function getLog() {
1436 * Returns the list of fields that can be imported
1438 * @param bool $prefix
1442 public static function &import($prefix = FALSE) {
1443 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contact', $prefix, []);
1448 * Returns the list of fields that can be exported
1450 * @param bool $prefix
1454 public static function &export($prefix = FALSE) {
1455 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contact', $prefix, []);
1460 * Returns the list of indices
1462 * @param bool $localize
1466 public static function indices($localize = TRUE) {
1468 'index_contact_type' => [
1469 'name' => 'index_contact_type',
1471 0 => 'contact_type',
1473 'localizable' => FALSE,
1474 'sig' => 'civicrm_contact::0::contact_type',
1476 'index_contact_sub_type' => [
1477 'name' => 'index_contact_sub_type',
1479 0 => 'contact_sub_type',
1481 'localizable' => FALSE,
1482 'sig' => 'civicrm_contact::0::contact_sub_type',
1484 'UI_external_identifier' => [
1485 'name' => 'UI_external_identifier',
1487 0 => 'external_identifier',
1489 'localizable' => FALSE,
1491 'sig' => 'civicrm_contact::1::external_identifier',
1493 'index_sort_name' => [
1494 'name' => 'index_sort_name',
1498 'localizable' => FALSE,
1499 'sig' => 'civicrm_contact::0::sort_name',
1501 'index_preferred_communication_method' => [
1502 'name' => 'index_preferred_communication_method',
1504 0 => 'preferred_communication_method',
1506 'localizable' => FALSE,
1507 'sig' => 'civicrm_contact::0::preferred_communication_method',
1510 'name' => 'index_hash',
1514 'localizable' => FALSE,
1515 'sig' => 'civicrm_contact::0::hash',
1517 'index_api_key' => [
1518 'name' => 'index_api_key',
1522 'localizable' => FALSE,
1523 'sig' => 'civicrm_contact::0::api_key',
1525 'index_first_name' => [
1526 'name' => 'index_first_name',
1530 'localizable' => FALSE,
1531 'sig' => 'civicrm_contact::0::first_name',
1533 'index_last_name' => [
1534 'name' => 'index_last_name',
1538 'localizable' => FALSE,
1539 'sig' => 'civicrm_contact::0::last_name',
1542 'name' => 'UI_prefix',
1546 'localizable' => FALSE,
1547 'sig' => 'civicrm_contact::0::prefix_id',
1550 'name' => 'UI_suffix',
1554 'localizable' => FALSE,
1555 'sig' => 'civicrm_contact::0::suffix_id',
1557 'index_communication_style_id' => [
1558 'name' => 'index_communication_style_id',
1560 0 => 'communication_style_id',
1562 'localizable' => FALSE,
1563 'sig' => 'civicrm_contact::0::communication_style_id',
1566 'name' => 'UI_gender',
1570 'localizable' => FALSE,
1571 'sig' => 'civicrm_contact::0::gender_id',
1573 'index_is_deceased' => [
1574 'name' => 'index_is_deceased',
1578 'localizable' => FALSE,
1579 'sig' => 'civicrm_contact::0::is_deceased',
1581 'index_household_name' => [
1582 'name' => 'index_household_name',
1584 0 => 'household_name',
1586 'localizable' => FALSE,
1587 'sig' => 'civicrm_contact::0::household_name',
1589 'index_organization_name' => [
1590 'name' => 'index_organization_name',
1592 0 => 'organization_name',
1594 'localizable' => FALSE,
1595 'sig' => 'civicrm_contact::0::organization_name',
1597 'index_is_deleted_sort_name' => [
1598 'name' => 'index_is_deleted_sort_name',
1604 'localizable' => FALSE,
1605 'sig' => 'civicrm_contact::0::is_deleted::sort_name::id',
1607 'index_created_date' => [
1608 'name' => 'index_created_date',
1610 0 => 'created_date',
1612 'localizable' => FALSE,
1613 'sig' => 'civicrm_contact::0::created_date',
1615 'index_modified_date' => [
1616 'name' => 'index_modified_date',
1618 0 => 'modified_date',
1620 'localizable' => FALSE,
1621 'sig' => 'civicrm_contact::0::modified_date',
1624 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;