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:1ed20aff22fc1effbd05ea8411e48139)
13 * Database access object for the Contact entity.
15 class CRM_Contact_DAO_Contact
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_contact';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-address-book-o';
34 * Field to show when displaying a record.
38 public static $_labelField = 'display_name';
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
45 public static $_log = TRUE;
48 * Paths for accessing this entity in the UI.
52 protected static $_paths = [
53 'add' => 'civicrm/contact/add?reset=1&ct=[contact_type]',
54 'view' => 'civicrm/contact/view?reset=1&cid=[id]',
55 'update' => 'civicrm/contact/add?reset=1&action=update&cid=[id]',
56 'delete' => 'civicrm/contact/view/delete?reset=1&delete=1&cid=[id]',
62 * @var int|string|null
63 * (SQL type: int unsigned)
64 * Note that values will be retrieved from the database as a string.
72 * (SQL type: varchar(64))
73 * Note that values will be retrieved from the database as a string.
78 * May be used to over-ride contact view and edit templates.
81 * (SQL type: varchar(255))
82 * Note that values will be retrieved from the database as a string.
84 public $contact_sub_type;
87 * @var bool|string|null
89 * Note that values will be retrieved from the database as a string.
94 * @var bool|string|null
96 * Note that values will be retrieved from the database as a string.
101 * @var bool|string|null
102 * (SQL type: tinyint)
103 * Note that values will be retrieved from the database as a string.
108 * @var bool|string|null
109 * (SQL type: tinyint)
110 * Note that values will be retrieved from the database as a string.
115 * @var bool|string|null
116 * (SQL type: tinyint)
117 * Note that values will be retrieved from the database as a string.
119 public $do_not_trade;
122 * Has the contact opted out from receiving all bulk email from the organization or site domain?
125 * (SQL type: tinyint)
126 * Note that values will be retrieved from the database as a string.
131 * May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.
134 * (SQL type: varchar(32))
135 * Note that values will be retrieved from the database as a string.
137 public $legal_identifier;
140 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
143 * (SQL type: varchar(64))
144 * Note that values will be retrieved from the database as a string.
146 public $external_identifier;
149 * Name used for sorting different contact types
152 * (SQL type: varchar(128))
153 * Note that values will be retrieved from the database as a string.
158 * Formatted name representing preferred format for display/print/other output.
161 * (SQL type: varchar(128))
162 * Note that values will be retrieved from the database as a string.
164 public $display_name;
170 * (SQL type: varchar(128))
171 * Note that values will be retrieved from the database as a string.
179 * (SQL type: varchar(128))
180 * Note that values will be retrieved from the database as a string.
185 * optional URL for preferred image (photo, logo, etc.) to display for this contact.
189 * Note that values will be retrieved from the database as a string.
194 * What is the preferred mode of communication.
197 * (SQL type: varchar(255))
198 * Note that values will be retrieved from the database as a string.
200 public $preferred_communication_method;
203 * Which language is preferred for communication. FK to languages in civicrm_option_value.
206 * (SQL type: varchar(5))
207 * Note that values will be retrieved from the database as a string.
209 public $preferred_language;
212 * What is the preferred mode of sending an email.
215 * (SQL type: varchar(8))
216 * Note that values will be retrieved from the database as a string.
218 public $preferred_mail_format;
221 * Key for validating requests related to this contact.
224 * (SQL type: varchar(32))
225 * Note that values will be retrieved from the database as a string.
230 * API Key for validating requests related to this contact.
233 * (SQL type: varchar(32))
234 * Note that values will be retrieved from the database as a string.
239 * where contact come from, e.g. import, donate module insert...
242 * (SQL type: varchar(255))
243 * Note that values will be retrieved from the database as a string.
251 * (SQL type: varchar(64))
252 * Note that values will be retrieved from the database as a string.
260 * (SQL type: varchar(64))
261 * Note that values will be retrieved from the database as a string.
269 * (SQL type: varchar(64))
270 * Note that values will be retrieved from the database as a string.
275 * Prefix or Title for name (Ms, Mr...). FK to prefix ID
277 * @var int|string|null
278 * (SQL type: int unsigned)
279 * Note that values will be retrieved from the database as a string.
284 * Suffix for name (Jr, Sr...). FK to suffix ID
286 * @var int|string|null
287 * (SQL type: int unsigned)
288 * Note that values will be retrieved from the database as a string.
293 * Formal (academic or similar) title in front of name. (Prof., Dr. etc.)
296 * (SQL type: varchar(64))
297 * Note that values will be retrieved from the database as a string.
299 public $formal_title;
302 * Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.
304 * @var int|string|null
305 * (SQL type: int unsigned)
306 * Note that values will be retrieved from the database as a string.
308 public $communication_style_id;
311 * FK to civicrm_option_value.id, that has to be valid registered Email Greeting.
313 * @var int|string|null
314 * (SQL type: int unsigned)
315 * Note that values will be retrieved from the database as a string.
317 public $email_greeting_id;
320 * Custom Email Greeting.
323 * (SQL type: varchar(128))
324 * Note that values will be retrieved from the database as a string.
326 public $email_greeting_custom;
329 * Cache Email Greeting.
332 * (SQL type: varchar(255))
333 * Note that values will be retrieved from the database as a string.
335 public $email_greeting_display;
338 * FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.
340 * @var int|string|null
341 * (SQL type: int unsigned)
342 * Note that values will be retrieved from the database as a string.
344 public $postal_greeting_id;
347 * Custom Postal greeting.
350 * (SQL type: varchar(128))
351 * Note that values will be retrieved from the database as a string.
353 public $postal_greeting_custom;
356 * Cache Postal greeting.
359 * (SQL type: varchar(255))
360 * Note that values will be retrieved from the database as a string.
362 public $postal_greeting_display;
365 * FK to civicrm_option_value.id, that has to be valid registered Addressee.
367 * @var int|string|null
368 * (SQL type: int unsigned)
369 * Note that values will be retrieved from the database as a string.
371 public $addressee_id;
377 * (SQL type: varchar(128))
378 * Note that values will be retrieved from the database as a string.
380 public $addressee_custom;
386 * (SQL type: varchar(255))
387 * Note that values will be retrieved from the database as a string.
389 public $addressee_display;
395 * (SQL type: varchar(255))
396 * Note that values will be retrieved from the database as a string.
403 * @var int|string|null
404 * (SQL type: int unsigned)
405 * Note that values will be retrieved from the database as a string.
414 * Note that values will be retrieved from the database as a string.
420 * (SQL type: tinyint)
421 * Note that values will be retrieved from the database as a string.
430 * Note that values will be retrieved from the database as a string.
432 public $deceased_date;
438 * (SQL type: varchar(128))
439 * Note that values will be retrieved from the database as a string.
441 public $household_name;
444 * Optional FK to Primary Contact for this household.
446 * @var int|string|null
447 * (SQL type: int unsigned)
448 * Note that values will be retrieved from the database as a string.
450 public $primary_contact_id;
456 * (SQL type: varchar(128))
457 * Note that values will be retrieved from the database as a string.
459 public $organization_name;
462 * Standard Industry Classification Code.
465 * (SQL type: varchar(8))
466 * Note that values will be retrieved from the database as a string.
471 * the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM
474 * (SQL type: varchar(255))
475 * Note that values will be retrieved from the database as a string.
477 public $user_unique_id;
480 * OPTIONAL FK to civicrm_contact record.
482 * @var int|string|null
483 * (SQL type: int unsigned)
484 * Note that values will be retrieved from the database as a string.
490 * (SQL type: tinyint)
491 * Note that values will be retrieved from the database as a string.
496 * When was the contact was created.
499 * (SQL type: timestamp)
500 * Note that values will be retrieved from the database as a string.
502 public $created_date;
505 * When was the contact (or closely related entity) was created or modified or deleted.
508 * (SQL type: timestamp)
509 * Note that values will be retrieved from the database as a string.
511 public $modified_date;
516 public function __construct() {
517 $this->__table
= 'civicrm_contact';
518 parent
::__construct();
522 * Returns localized title of this entity.
524 * @param bool $plural
525 * Whether to return the plural version of the title.
527 public static function getEntityTitle($plural = FALSE) {
528 return $plural ?
ts('Contacts') : ts('Contact');
532 * Returns user-friendly description of this entity.
536 public static function getEntityDescription() {
537 return ts('Individuals, organizations, households, etc.');
541 * Returns foreign keys and entity references.
544 * [CRM_Core_Reference_Interface]
546 public static function getReferenceColumns() {
547 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
548 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
549 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'primary_contact_id', 'civicrm_contact', 'id');
550 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'employer_id', 'civicrm_contact', 'id');
551 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
553 return Civi
::$statics[__CLASS__
]['links'];
557 * Returns all the column names of this table
561 public static function &fields() {
562 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
563 Civi
::$statics[__CLASS__
]['fields'] = [
566 'type' => CRM_Utils_Type
::T_INT
,
567 'title' => ts('Contact ID'),
568 'description' => ts('Unique Contact ID'),
571 'where' => 'civicrm_contact.id',
572 'headerPattern' => '/internal|contact?|id$/i',
574 'table_name' => 'civicrm_contact',
575 'entity' => 'Contact',
576 'bao' => 'CRM_Contact_BAO_Contact',
585 'name' => 'contact_type',
586 'type' => CRM_Utils_Type
::T_STRING
,
587 'title' => ts('Contact Type'),
588 'description' => ts('Type of Contact.'),
590 'size' => CRM_Utils_Type
::BIG
,
591 'where' => 'civicrm_contact.contact_type',
593 'contactType' => NULL,
594 'table_name' => 'civicrm_contact',
595 'entity' => 'Contact',
596 'bao' => 'CRM_Contact_BAO_Contact',
601 'pseudoconstant' => [
602 'table' => 'civicrm_contact_type',
603 'keyColumn' => 'name',
604 'labelColumn' => 'label',
605 'condition' => 'parent_id IS NULL',
610 'contact_sub_type' => [
611 'name' => 'contact_sub_type',
612 'type' => CRM_Utils_Type
::T_STRING
,
613 'title' => ts('Contact Subtype'),
614 'description' => ts('May be used to over-ride contact view and edit templates.'),
616 'size' => CRM_Utils_Type
::HUGE
,
618 'where' => 'civicrm_contact.contact_sub_type',
619 'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
621 'table_name' => 'civicrm_contact',
622 'entity' => 'Contact',
623 'bao' => 'CRM_Contact_BAO_Contact',
625 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
629 'pseudoconstant' => [
630 'table' => 'civicrm_contact_type',
631 'keyColumn' => 'name',
632 'labelColumn' => 'label',
633 'condition' => 'parent_id IS NOT NULL',
638 'name' => 'do_not_email',
639 'type' => CRM_Utils_Type
::T_BOOLEAN
,
640 'title' => ts('Do Not Email'),
642 'where' => 'civicrm_contact.do_not_email',
643 'headerPattern' => '/d(o )?(not )?(email)/i',
644 'dataPattern' => '/^\d{1,}$/',
647 'table_name' => 'civicrm_contact',
648 'entity' => 'Contact',
649 'bao' => 'CRM_Contact_BAO_Contact',
652 'type' => 'CheckBox',
653 'label' => ts("Do Not Email"),
658 'name' => 'do_not_phone',
659 'type' => CRM_Utils_Type
::T_BOOLEAN
,
660 'title' => ts('Do Not Phone'),
662 'where' => 'civicrm_contact.do_not_phone',
663 'headerPattern' => '/d(o )?(not )?(call|phone)/i',
664 'dataPattern' => '/^\d{1,}$/',
667 'table_name' => 'civicrm_contact',
668 'entity' => 'Contact',
669 'bao' => 'CRM_Contact_BAO_Contact',
672 'type' => 'CheckBox',
673 'label' => ts("Do Not Phone"),
678 'name' => 'do_not_mail',
679 'type' => CRM_Utils_Type
::T_BOOLEAN
,
680 'title' => ts('Do Not Mail'),
682 'where' => 'civicrm_contact.do_not_mail',
683 'headerPattern' => '/^(d(o\s)?n(ot\s)?mail)|(\w*)?bulk\s?(\w*)$/i',
684 'dataPattern' => '/^\d{1,}$/',
687 'table_name' => 'civicrm_contact',
688 'entity' => 'Contact',
689 'bao' => 'CRM_Contact_BAO_Contact',
692 'type' => 'CheckBox',
693 'label' => ts("Do Not Mail"),
698 'name' => 'do_not_sms',
699 'type' => CRM_Utils_Type
::T_BOOLEAN
,
700 'title' => ts('Do Not Sms'),
702 'where' => 'civicrm_contact.do_not_sms',
703 'headerPattern' => '/d(o )?(not )?(sms)/i',
704 'dataPattern' => '/^\d{1,}$/',
707 'table_name' => 'civicrm_contact',
708 'entity' => 'Contact',
709 'bao' => 'CRM_Contact_BAO_Contact',
712 'type' => 'CheckBox',
713 'label' => ts("Do Not Sms"),
718 'name' => 'do_not_trade',
719 'type' => CRM_Utils_Type
::T_BOOLEAN
,
720 'title' => ts('Do Not Trade'),
722 'where' => 'civicrm_contact.do_not_trade',
723 'headerPattern' => '/d(o )?(not )?(trade)/i',
724 'dataPattern' => '/^\d{1,}$/',
727 'table_name' => 'civicrm_contact',
728 'entity' => 'Contact',
729 'bao' => 'CRM_Contact_BAO_Contact',
732 'type' => 'CheckBox',
733 'label' => ts("Do Not Trade"),
738 'name' => 'is_opt_out',
739 'type' => CRM_Utils_Type
::T_BOOLEAN
,
740 'title' => ts('No Bulk Emails (User Opt Out)'),
741 'description' => ts('Has the contact opted out from receiving all bulk email from the organization or site domain?'),
744 'where' => 'civicrm_contact.is_opt_out',
747 'table_name' => 'civicrm_contact',
748 'entity' => 'Contact',
749 'bao' => 'CRM_Contact_BAO_Contact',
752 'type' => 'CheckBox',
753 'label' => ts("Is Opt Out"),
757 'legal_identifier' => [
758 'name' => 'legal_identifier',
759 'type' => CRM_Utils_Type
::T_STRING
,
760 'title' => ts('Legal Identifier'),
761 'description' => ts('May be used for SSN, EIN/TIN, Household ID (census) or other applicable unique legal/government ID.'),
763 'size' => CRM_Utils_Type
::MEDIUM
,
765 'where' => 'civicrm_contact.legal_identifier',
766 'headerPattern' => '/legal\s?id/i',
767 'dataPattern' => '/\w+?\d{5,}/',
769 'table_name' => 'civicrm_contact',
770 'entity' => 'Contact',
771 'bao' => 'CRM_Contact_BAO_Contact',
775 'label' => ts("Legal Identifier"),
779 'external_identifier' => [
780 'name' => 'external_identifier',
781 'type' => CRM_Utils_Type
::T_STRING
,
782 'title' => ts('External Identifier'),
783 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
787 'where' => 'civicrm_contact.external_identifier',
788 'headerPattern' => '/external\s?id/i',
789 'dataPattern' => '/^\d{11,}$/',
791 'table_name' => 'civicrm_contact',
792 'entity' => 'Contact',
793 'bao' => 'CRM_Contact_BAO_Contact',
797 'label' => ts("External Identifier"),
802 'name' => 'sort_name',
803 'type' => CRM_Utils_Type
::T_STRING
,
804 'title' => ts('Sort Name'),
805 'description' => ts('Name used for sorting different contact types'),
808 'where' => 'civicrm_contact.sort_name',
810 'table_name' => 'civicrm_contact',
811 'entity' => 'Contact',
812 'bao' => 'CRM_Contact_BAO_Contact',
821 'name' => 'display_name',
822 'type' => CRM_Utils_Type
::T_STRING
,
823 'title' => ts('Display Name'),
824 'description' => ts('Formatted name representing preferred format for display/print/other output.'),
827 'where' => 'civicrm_contact.display_name',
829 'table_name' => 'civicrm_contact',
830 'entity' => 'Contact',
831 'bao' => 'CRM_Contact_BAO_Contact',
840 'name' => 'nick_name',
841 'type' => CRM_Utils_Type
::T_STRING
,
842 'title' => ts('Nickname'),
843 'description' => ts('Nickname.'),
847 'where' => 'civicrm_contact.nick_name',
848 'headerPattern' => '/n(ick\s)name|nick$/i',
849 'dataPattern' => '/^\w+$/',
851 'table_name' => 'civicrm_contact',
852 'entity' => 'Contact',
853 'bao' => 'CRM_Contact_BAO_Contact',
861 'name' => 'legal_name',
862 'type' => CRM_Utils_Type
::T_STRING
,
863 'title' => ts('Legal Name'),
864 'description' => ts('Legal Name.'),
868 'where' => 'civicrm_contact.legal_name',
869 'headerPattern' => '/^legal|(l(egal\s)?name)$/i',
871 'contactType' => 'Organization',
872 'table_name' => 'civicrm_contact',
873 'entity' => 'Contact',
874 'bao' => 'CRM_Contact_BAO_Contact',
878 'label' => ts("Legal Name"),
883 'name' => 'image_URL',
884 'type' => CRM_Utils_Type
::T_TEXT
,
885 'title' => ts('Image Url'),
886 'description' => ts('optional URL for preferred image (photo, logo, etc.) to display for this contact.'),
888 'where' => 'civicrm_contact.image_URL',
890 'table_name' => 'civicrm_contact',
891 'entity' => 'Contact',
892 'bao' => 'CRM_Contact_BAO_Contact',
896 'label' => ts("Image URL"),
900 'preferred_communication_method' => [
901 'name' => 'preferred_communication_method',
902 'type' => CRM_Utils_Type
::T_STRING
,
903 'title' => ts('Preferred Communication Method'),
904 'description' => ts('What is the preferred mode of communication.'),
906 'size' => CRM_Utils_Type
::HUGE
,
908 'where' => 'civicrm_contact.preferred_communication_method',
909 'headerPattern' => '/^p(ref\w*\s)?c(omm\w*)|( meth\w*)$/i',
910 'dataPattern' => '/^\w+$/',
912 'table_name' => 'civicrm_contact',
913 'entity' => 'Contact',
914 'bao' => 'CRM_Contact_BAO_Contact',
916 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
920 'pseudoconstant' => [
921 'optionGroupName' => 'preferred_communication_method',
922 'optionEditPath' => 'civicrm/admin/options/preferred_communication_method',
926 'preferred_language' => [
927 'name' => 'preferred_language',
928 'type' => CRM_Utils_Type
::T_STRING
,
929 'title' => ts('Preferred Language'),
930 'description' => ts('Which language is preferred for communication. FK to languages in civicrm_option_value.'),
932 'size' => CRM_Utils_Type
::SIX
,
934 'where' => 'civicrm_contact.preferred_language',
935 'headerPattern' => '/^lang/i',
937 'table_name' => 'civicrm_contact',
938 'entity' => 'Contact',
939 'bao' => 'CRM_Contact_BAO_Contact',
944 'pseudoconstant' => [
945 'optionGroupName' => 'languages',
946 'keyColumn' => 'name',
947 'optionEditPath' => 'civicrm/admin/options/languages',
951 'preferred_mail_format' => [
952 'name' => 'preferred_mail_format',
953 'type' => CRM_Utils_Type
::T_STRING
,
954 'title' => ts('Preferred Mail Format'),
955 'description' => ts('What is the preferred mode of sending an email.'),
957 'size' => CRM_Utils_Type
::EIGHT
,
959 'where' => 'civicrm_contact.preferred_mail_format',
960 'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i',
963 'table_name' => 'civicrm_contact',
964 'entity' => 'Contact',
965 'bao' => 'CRM_Contact_BAO_Contact',
969 'label' => ts("Preferred Mail Format"),
971 'pseudoconstant' => [
972 'callback' => 'CRM_Core_SelectValues::pmf',
978 'type' => CRM_Utils_Type
::T_STRING
,
979 'title' => ts('Contact Hash'),
980 'description' => ts('Key for validating requests related to this contact.'),
982 'size' => CRM_Utils_Type
::MEDIUM
,
983 'where' => 'civicrm_contact.hash',
985 'table_name' => 'civicrm_contact',
986 'entity' => 'Contact',
987 'bao' => 'CRM_Contact_BAO_Contact',
994 'type' => CRM_Utils_Type
::T_STRING
,
995 'title' => ts('Api Key'),
996 'description' => ts('API Key for validating requests related to this contact.'),
998 'size' => CRM_Utils_Type
::MEDIUM
,
999 'where' => 'civicrm_contact.api_key',
1002 'administer CiviCRM',
1006 'table_name' => 'civicrm_contact',
1007 'entity' => 'Contact',
1008 'bao' => 'CRM_Contact_BAO_Contact',
1011 'label' => ts("API KEY"),
1016 'contact_source' => [
1018 'type' => CRM_Utils_Type
::T_STRING
,
1019 'title' => ts('Contact Source'),
1020 'description' => ts('where contact come from, e.g. import, donate module insert...'),
1024 'where' => 'civicrm_contact.source',
1025 'headerPattern' => '/(C(ontact\s)?Source)$/i',
1027 'table_name' => 'civicrm_contact',
1028 'entity' => 'Contact',
1029 'bao' => 'CRM_Contact_BAO_Contact',
1037 'name' => 'first_name',
1038 'type' => CRM_Utils_Type
::T_STRING
,
1039 'title' => ts('First Name'),
1040 'description' => ts('First Name.'),
1044 'where' => 'civicrm_contact.first_name',
1045 'headerPattern' => '/^first|(f(irst\s)?name)$/i',
1046 'dataPattern' => '/^\w+$/',
1048 'contactType' => 'Individual',
1049 'table_name' => 'civicrm_contact',
1050 'entity' => 'Contact',
1051 'bao' => 'CRM_Contact_BAO_Contact',
1055 'label' => ts("First Name"),
1060 'name' => 'middle_name',
1061 'type' => CRM_Utils_Type
::T_STRING
,
1062 'title' => ts('Middle Name'),
1063 'description' => ts('Middle Name.'),
1067 'where' => 'civicrm_contact.middle_name',
1068 'headerPattern' => '/^middle|(m(iddle\s)?name)$/i',
1069 'dataPattern' => '/^\w+$/',
1071 'contactType' => 'Individual',
1072 'table_name' => 'civicrm_contact',
1073 'entity' => 'Contact',
1074 'bao' => 'CRM_Contact_BAO_Contact',
1078 'label' => ts("Middle Name"),
1083 'name' => 'last_name',
1084 'type' => CRM_Utils_Type
::T_STRING
,
1085 'title' => ts('Last Name'),
1086 'description' => ts('Last Name.'),
1090 'where' => 'civicrm_contact.last_name',
1091 'headerPattern' => '/^last|(l(ast\s)?name)$/i',
1092 'dataPattern' => '/^\w+(\s\w+)?+$/',
1094 'contactType' => 'Individual',
1095 'table_name' => 'civicrm_contact',
1096 'entity' => 'Contact',
1097 'bao' => 'CRM_Contact_BAO_Contact',
1101 'label' => ts("Last Name"),
1106 'name' => 'prefix_id',
1107 'type' => CRM_Utils_Type
::T_INT
,
1108 'title' => ts('Individual Prefix'),
1109 'description' => ts('Prefix or Title for name (Ms, Mr...). FK to prefix ID'),
1111 'where' => 'civicrm_contact.prefix_id',
1112 'headerPattern' => '/^(prefix|title)/i',
1113 'dataPattern' => '/^(mr|ms|mrs|sir|dr)\.?$/i',
1115 'contactType' => 'Individual',
1116 'table_name' => 'civicrm_contact',
1117 'entity' => 'Contact',
1118 'bao' => 'CRM_Contact_BAO_Contact',
1123 'pseudoconstant' => [
1124 'optionGroupName' => 'individual_prefix',
1125 'optionEditPath' => 'civicrm/admin/options/individual_prefix',
1130 'name' => 'suffix_id',
1131 'type' => CRM_Utils_Type
::T_INT
,
1132 'title' => ts('Individual Suffix'),
1133 'description' => ts('Suffix for name (Jr, Sr...). FK to suffix ID'),
1135 'where' => 'civicrm_contact.suffix_id',
1136 'headerPattern' => '/^suffix$/i',
1137 'dataPattern' => '/^(sr|jr)\.?|i{2,}$/',
1139 'contactType' => 'Individual',
1140 'table_name' => 'civicrm_contact',
1141 'entity' => 'Contact',
1142 'bao' => 'CRM_Contact_BAO_Contact',
1147 'pseudoconstant' => [
1148 'optionGroupName' => 'individual_suffix',
1149 'optionEditPath' => 'civicrm/admin/options/individual_suffix',
1154 'name' => 'formal_title',
1155 'type' => CRM_Utils_Type
::T_STRING
,
1156 'title' => ts('Formal Title'),
1157 'description' => ts('Formal (academic or similar) title in front of name. (Prof., Dr. etc.)'),
1159 'size' => CRM_Utils_Type
::BIG
,
1161 'where' => 'civicrm_contact.formal_title',
1162 'headerPattern' => '/^title/i',
1164 'contactType' => 'Individual',
1165 'table_name' => 'civicrm_contact',
1166 'entity' => 'Contact',
1167 'bao' => 'CRM_Contact_BAO_Contact',
1171 'label' => ts("Formal Title"),
1175 'communication_style_id' => [
1176 'name' => 'communication_style_id',
1177 'type' => CRM_Utils_Type
::T_INT
,
1178 'title' => ts('Communication Style'),
1179 'description' => ts('Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.'),
1181 'where' => 'civicrm_contact.communication_style_id',
1182 'headerPattern' => '/style/i',
1184 'table_name' => 'civicrm_contact',
1185 'entity' => 'Contact',
1186 'bao' => 'CRM_Contact_BAO_Contact',
1191 'pseudoconstant' => [
1192 'optionGroupName' => 'communication_style',
1193 'optionEditPath' => 'civicrm/admin/options/communication_style',
1197 'email_greeting_id' => [
1198 'name' => 'email_greeting_id',
1199 'type' => CRM_Utils_Type
::T_INT
,
1200 'title' => ts('Email Greeting ID'),
1201 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Email Greeting.'),
1202 'where' => 'civicrm_contact.email_greeting_id',
1204 'table_name' => 'civicrm_contact',
1205 'entity' => 'Contact',
1206 'bao' => 'CRM_Contact_BAO_Contact',
1211 'pseudoconstant' => [
1212 'optionGroupName' => 'email_greeting',
1213 'optionEditPath' => 'civicrm/admin/options/email_greeting',
1217 'email_greeting_custom' => [
1218 'name' => 'email_greeting_custom',
1219 'type' => CRM_Utils_Type
::T_STRING
,
1220 'title' => ts('Email Greeting Custom'),
1221 'description' => ts('Custom Email Greeting.'),
1223 'size' => CRM_Utils_Type
::HUGE
,
1225 'where' => 'civicrm_contact.email_greeting_custom',
1227 'table_name' => 'civicrm_contact',
1228 'entity' => 'Contact',
1229 'bao' => 'CRM_Contact_BAO_Contact',
1233 'label' => ts("Email Greeting Custom"),
1237 'email_greeting_display' => [
1238 'name' => 'email_greeting_display',
1239 'type' => CRM_Utils_Type
::T_STRING
,
1240 'title' => ts('Email Greeting'),
1241 'description' => ts('Cache Email Greeting.'),
1243 'size' => CRM_Utils_Type
::HUGE
,
1244 'where' => 'civicrm_contact.email_greeting_display',
1245 'table_name' => 'civicrm_contact',
1246 'entity' => 'Contact',
1247 'bao' => 'CRM_Contact_BAO_Contact',
1252 'postal_greeting_id' => [
1253 'name' => 'postal_greeting_id',
1254 'type' => CRM_Utils_Type
::T_INT
,
1255 'title' => ts('Postal Greeting ID'),
1256 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.'),
1257 'where' => 'civicrm_contact.postal_greeting_id',
1259 'table_name' => 'civicrm_contact',
1260 'entity' => 'Contact',
1261 'bao' => 'CRM_Contact_BAO_Contact',
1266 'pseudoconstant' => [
1267 'optionGroupName' => 'postal_greeting',
1268 'optionEditPath' => 'civicrm/admin/options/postal_greeting',
1272 'postal_greeting_custom' => [
1273 'name' => 'postal_greeting_custom',
1274 'type' => CRM_Utils_Type
::T_STRING
,
1275 'title' => ts('Postal Greeting Custom'),
1276 'description' => ts('Custom Postal greeting.'),
1278 'size' => CRM_Utils_Type
::HUGE
,
1280 'where' => 'civicrm_contact.postal_greeting_custom',
1282 'table_name' => 'civicrm_contact',
1283 'entity' => 'Contact',
1284 'bao' => 'CRM_Contact_BAO_Contact',
1288 'label' => ts("Postal Greeting Custom"),
1292 'postal_greeting_display' => [
1293 'name' => 'postal_greeting_display',
1294 'type' => CRM_Utils_Type
::T_STRING
,
1295 'title' => ts('Postal Greeting'),
1296 'description' => ts('Cache Postal greeting.'),
1298 'size' => CRM_Utils_Type
::HUGE
,
1299 'where' => 'civicrm_contact.postal_greeting_display',
1300 'table_name' => 'civicrm_contact',
1301 'entity' => 'Contact',
1302 'bao' => 'CRM_Contact_BAO_Contact',
1308 'name' => 'addressee_id',
1309 'type' => CRM_Utils_Type
::T_INT
,
1310 'title' => ts('Addressee ID'),
1311 'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Addressee.'),
1312 'where' => 'civicrm_contact.addressee_id',
1314 'table_name' => 'civicrm_contact',
1315 'entity' => 'Contact',
1316 'bao' => 'CRM_Contact_BAO_Contact',
1321 'pseudoconstant' => [
1322 'optionGroupName' => 'addressee',
1323 'optionEditPath' => 'civicrm/admin/options/addressee',
1327 'addressee_custom' => [
1328 'name' => 'addressee_custom',
1329 'type' => CRM_Utils_Type
::T_STRING
,
1330 'title' => ts('Addressee Custom'),
1331 'description' => ts('Custom Addressee.'),
1333 'size' => CRM_Utils_Type
::HUGE
,
1335 'where' => 'civicrm_contact.addressee_custom',
1337 'table_name' => 'civicrm_contact',
1338 'entity' => 'Contact',
1339 'bao' => 'CRM_Contact_BAO_Contact',
1343 'label' => ts("Addressee Custom"),
1347 'addressee_display' => [
1348 'name' => 'addressee_display',
1349 'type' => CRM_Utils_Type
::T_STRING
,
1350 'title' => ts('Addressee'),
1351 'description' => ts('Cache Addressee.'),
1353 'size' => CRM_Utils_Type
::HUGE
,
1354 'where' => 'civicrm_contact.addressee_display',
1355 'table_name' => 'civicrm_contact',
1356 'entity' => 'Contact',
1357 'bao' => 'CRM_Contact_BAO_Contact',
1363 'name' => 'job_title',
1364 'type' => CRM_Utils_Type
::T_STRING
,
1365 'title' => ts('Job Title'),
1366 'description' => ts('Job Title'),
1370 'where' => 'civicrm_contact.job_title',
1371 'headerPattern' => '/^job|(j(ob\s)?title)$/i',
1372 'dataPattern' => '//',
1374 'contactType' => 'Individual',
1375 'table_name' => 'civicrm_contact',
1376 'entity' => 'Contact',
1377 'bao' => 'CRM_Contact_BAO_Contact',
1381 'label' => ts("Job Title"),
1386 'name' => 'gender_id',
1387 'type' => CRM_Utils_Type
::T_INT
,
1388 'title' => ts('Gender ID'),
1389 'description' => ts('FK to gender ID'),
1391 'where' => 'civicrm_contact.gender_id',
1392 'headerPattern' => '/^gender$/i',
1394 'contactType' => 'Individual',
1395 'table_name' => 'civicrm_contact',
1396 'entity' => 'Contact',
1397 'bao' => 'CRM_Contact_BAO_Contact',
1401 'label' => ts("Gender"),
1403 'pseudoconstant' => [
1404 'optionGroupName' => 'gender',
1405 'optionEditPath' => 'civicrm/admin/options/gender',
1410 'name' => 'birth_date',
1411 'type' => CRM_Utils_Type
::T_DATE
,
1412 'title' => ts('Birth Date'),
1413 'description' => ts('Date of birth'),
1415 'where' => 'civicrm_contact.birth_date',
1416 'headerPattern' => '/^birth|(b(irth\s)?date)|D(\W*)O(\W*)B(\W*)$/i',
1417 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
1419 'contactType' => 'Individual',
1420 'table_name' => 'civicrm_contact',
1421 'entity' => 'Contact',
1422 'bao' => 'CRM_Contact_BAO_Contact',
1425 'type' => 'Select Date',
1426 'formatType' => 'birth',
1427 'label' => ts("Birth Date"),
1432 'name' => 'is_deceased',
1433 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1434 'title' => ts('Deceased'),
1437 'where' => 'civicrm_contact.is_deceased',
1438 'headerPattern' => '/i(s\s)?d(eceased)$/i',
1440 'contactType' => 'Individual',
1442 'table_name' => 'civicrm_contact',
1443 'entity' => 'Contact',
1444 'bao' => 'CRM_Contact_BAO_Contact',
1447 'type' => 'CheckBox',
1448 'label' => ts("Is Deceased"),
1452 'deceased_date' => [
1453 'name' => 'deceased_date',
1454 'type' => CRM_Utils_Type
::T_DATE
,
1455 'title' => ts('Deceased Date'),
1456 'description' => ts('Date of deceased'),
1458 'where' => 'civicrm_contact.deceased_date',
1459 'headerPattern' => '/^deceased|(d(eceased\s)?date)$/i',
1461 'contactType' => 'Individual',
1462 'table_name' => 'civicrm_contact',
1463 'entity' => 'Contact',
1464 'bao' => 'CRM_Contact_BAO_Contact',
1467 'type' => 'Select Date',
1468 'formatType' => 'birth',
1469 'label' => ts("Deceased Date"),
1473 'household_name' => [
1474 'name' => 'household_name',
1475 'type' => CRM_Utils_Type
::T_STRING
,
1476 'title' => ts('Household Name'),
1477 'description' => ts('Household Name.'),
1481 'where' => 'civicrm_contact.household_name',
1482 'headerPattern' => '/^household|(h(ousehold\s)?name)$/i',
1483 'dataPattern' => '/^\w+$/',
1485 'contactType' => 'Household',
1486 'table_name' => 'civicrm_contact',
1487 'entity' => 'Contact',
1488 'bao' => 'CRM_Contact_BAO_Contact',
1492 'label' => ts("Household Name"),
1496 'primary_contact_id' => [
1497 'name' => 'primary_contact_id',
1498 'type' => CRM_Utils_Type
::T_INT
,
1499 'title' => ts('Household Primary Contact ID'),
1500 'description' => ts('Optional FK to Primary Contact for this household.'),
1501 'where' => 'civicrm_contact.primary_contact_id',
1502 'contactType' => 'Household',
1503 'table_name' => 'civicrm_contact',
1504 'entity' => 'Contact',
1505 'bao' => 'CRM_Contact_BAO_Contact',
1507 'FKClassName' => 'CRM_Contact_DAO_Contact',
1509 'label' => ts("Household Primary Contact"),
1514 'organization_name' => [
1515 'name' => 'organization_name',
1516 'type' => CRM_Utils_Type
::T_STRING
,
1517 'title' => ts('Organization Name'),
1518 'description' => ts('Organization Name.'),
1522 'where' => 'civicrm_contact.organization_name',
1523 'headerPattern' => '/^organization|(o(rganization\s)?name)$/i',
1524 'dataPattern' => '/^\w+$/',
1526 'contactType' => 'Organization',
1527 'table_name' => 'civicrm_contact',
1528 'entity' => 'Contact',
1529 'bao' => 'CRM_Contact_BAO_Contact',
1533 'label' => ts("Organization Name"),
1538 'name' => 'sic_code',
1539 'type' => CRM_Utils_Type
::T_STRING
,
1540 'title' => ts('Sic Code'),
1541 'description' => ts('Standard Industry Classification Code.'),
1543 'size' => CRM_Utils_Type
::EIGHT
,
1545 'where' => 'civicrm_contact.sic_code',
1546 'headerPattern' => '/^sic|(s(ic\s)?code)$/i',
1548 'contactType' => 'Organization',
1549 'table_name' => 'civicrm_contact',
1550 'entity' => 'Contact',
1551 'bao' => 'CRM_Contact_BAO_Contact',
1555 'label' => ts("SIC Code"),
1559 'user_unique_id' => [
1560 'name' => 'user_unique_id',
1561 'type' => CRM_Utils_Type
::T_STRING
,
1562 'title' => ts('Unique ID (OpenID)'),
1563 'description' => ts('the OpenID (or OpenID-style http://username.domain/) unique identifier for this contact mainly used for logging in to CiviCRM'),
1565 'size' => CRM_Utils_Type
::HUGE
,
1567 'where' => 'civicrm_contact.user_unique_id',
1568 'headerPattern' => '/^Open\s?ID|u(niq\w*)?\s?ID/i',
1569 'dataPattern' => '/^[\w\/\:\.]+$/',
1572 'table_name' => 'civicrm_contact',
1573 'entity' => 'Contact',
1574 'bao' => 'CRM_Contact_BAO_Contact',
1581 'current_employer_id' => [
1582 'name' => 'employer_id',
1583 'type' => CRM_Utils_Type
::T_INT
,
1584 'title' => ts('Current Employer ID'),
1585 'description' => ts('OPTIONAL FK to civicrm_contact record.'),
1586 'where' => 'civicrm_contact.employer_id',
1588 'contactType' => 'Individual',
1589 'table_name' => 'civicrm_contact',
1590 'entity' => 'Contact',
1591 'bao' => 'CRM_Contact_BAO_Contact',
1593 'FKClassName' => 'CRM_Contact_DAO_Contact',
1595 'type' => 'EntityRef',
1596 'label' => ts("Current Employer"),
1600 'contact_is_deleted' => [
1601 'name' => 'is_deleted',
1602 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1603 'title' => ts('Contact is in Trash'),
1605 'where' => 'civicrm_contact.is_deleted',
1608 'table_name' => 'civicrm_contact',
1609 'entity' => 'Contact',
1610 'bao' => 'CRM_Contact_BAO_Contact',
1613 'type' => 'CheckBox',
1618 'name' => 'created_date',
1619 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1620 'title' => ts('Created Date'),
1621 'description' => ts('When was the contact was created.'),
1622 'required' => FALSE,
1623 'where' => 'civicrm_contact.created_date',
1626 'table_name' => 'civicrm_contact',
1627 'entity' => 'Contact',
1628 'bao' => 'CRM_Contact_BAO_Contact',
1631 'label' => ts("Created Date"),
1635 'modified_date' => [
1636 'name' => 'modified_date',
1637 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1638 'title' => ts('Modified Date'),
1639 'description' => ts('When was the contact (or closely related entity) was created or modified or deleted.'),
1640 'required' => FALSE,
1641 'where' => 'civicrm_contact.modified_date',
1643 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
1644 'table_name' => 'civicrm_contact',
1645 'entity' => 'Contact',
1646 'bao' => 'CRM_Contact_BAO_Contact',
1649 'label' => ts("Modified Date"),
1655 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
1657 return Civi
::$statics[__CLASS__
]['fields'];
1661 * Return a mapping from field-name to the corresponding key (as used in fields()).
1664 * Array(string $name => string $uniqueName).
1666 public static function &fieldKeys() {
1667 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
1668 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
1670 return Civi
::$statics[__CLASS__
]['fieldKeys'];
1674 * Returns the names of this table
1678 public static function getTableName() {
1679 return self
::$_tableName;
1683 * Returns if this table needs to be logged
1687 public function getLog() {
1692 * Returns the list of fields that can be imported
1694 * @param bool $prefix
1698 public static function &import($prefix = FALSE) {
1699 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contact', $prefix, []);
1704 * Returns the list of fields that can be exported
1706 * @param bool $prefix
1710 public static function &export($prefix = FALSE) {
1711 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contact', $prefix, []);
1716 * Returns the list of indices
1718 * @param bool $localize
1722 public static function indices($localize = TRUE) {
1724 'index_contact_type' => [
1725 'name' => 'index_contact_type',
1727 0 => 'contact_type',
1729 'localizable' => FALSE,
1730 'sig' => 'civicrm_contact::0::contact_type',
1732 'index_contact_sub_type' => [
1733 'name' => 'index_contact_sub_type',
1735 0 => 'contact_sub_type',
1737 'localizable' => FALSE,
1738 'sig' => 'civicrm_contact::0::contact_sub_type',
1740 'UI_external_identifier' => [
1741 'name' => 'UI_external_identifier',
1743 0 => 'external_identifier',
1745 'localizable' => FALSE,
1747 'sig' => 'civicrm_contact::1::external_identifier',
1749 'index_sort_name' => [
1750 'name' => 'index_sort_name',
1754 'localizable' => FALSE,
1755 'sig' => 'civicrm_contact::0::sort_name',
1757 'index_preferred_communication_method' => [
1758 'name' => 'index_preferred_communication_method',
1760 0 => 'preferred_communication_method',
1762 'localizable' => FALSE,
1763 'sig' => 'civicrm_contact::0::preferred_communication_method',
1766 'name' => 'index_hash',
1770 'localizable' => FALSE,
1771 'sig' => 'civicrm_contact::0::hash',
1773 'index_api_key' => [
1774 'name' => 'index_api_key',
1778 'localizable' => FALSE,
1779 'sig' => 'civicrm_contact::0::api_key',
1781 'index_first_name' => [
1782 'name' => 'index_first_name',
1786 'localizable' => FALSE,
1787 'sig' => 'civicrm_contact::0::first_name',
1789 'index_last_name' => [
1790 'name' => 'index_last_name',
1794 'localizable' => FALSE,
1795 'sig' => 'civicrm_contact::0::last_name',
1798 'name' => 'UI_prefix',
1802 'localizable' => FALSE,
1803 'sig' => 'civicrm_contact::0::prefix_id',
1806 'name' => 'UI_suffix',
1810 'localizable' => FALSE,
1811 'sig' => 'civicrm_contact::0::suffix_id',
1813 'index_communication_style_id' => [
1814 'name' => 'index_communication_style_id',
1816 0 => 'communication_style_id',
1818 'localizable' => FALSE,
1819 'sig' => 'civicrm_contact::0::communication_style_id',
1822 'name' => 'UI_gender',
1826 'localizable' => FALSE,
1827 'sig' => 'civicrm_contact::0::gender_id',
1829 'index_is_deceased' => [
1830 'name' => 'index_is_deceased',
1834 'localizable' => FALSE,
1835 'sig' => 'civicrm_contact::0::is_deceased',
1837 'index_household_name' => [
1838 'name' => 'index_household_name',
1840 0 => 'household_name',
1842 'localizable' => FALSE,
1843 'sig' => 'civicrm_contact::0::household_name',
1845 'index_organization_name' => [
1846 'name' => 'index_organization_name',
1848 0 => 'organization_name',
1850 'localizable' => FALSE,
1851 'sig' => 'civicrm_contact::0::organization_name',
1853 'index_is_deleted_sort_name' => [
1854 'name' => 'index_is_deleted_sort_name',
1860 'localizable' => FALSE,
1861 'sig' => 'civicrm_contact::0::is_deleted::sort_name::id',
1863 'index_created_date' => [
1864 'name' => 'index_created_date',
1866 0 => 'created_date',
1868 'localizable' => FALSE,
1869 'sig' => 'civicrm_contact::0::created_date',
1871 'index_modified_date' => [
1872 'name' => 'index_modified_date',
1874 0 => 'modified_date',
1876 'localizable' => FALSE,
1877 'sig' => 'civicrm_contact::0::modified_date',
1880 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;