5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/Address.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ecd12ccf6f73ab607645bb57298e8366)
13 * Database access object for the Address entity.
15 class CRM_Core_DAO_Address
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_address';
25 * Icon associated with this entity.
29 public static $_icon = 'fa-map-marker';
32 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 public static $_log = TRUE;
53 * Which Location does this address belong to.
57 public $location_type_id;
60 * Is this the primary address.
67 * Is this the billing address.
74 * Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
75 * number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
80 public $street_address;
83 * Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.
87 public $street_number;
90 * Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A
94 public $street_number_suffix;
97 * Directional prefix, e.g. SE Main St, SE is the prefix.
101 public $street_number_predirectional;
104 * Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.
118 * Directional prefix, e.g. Main St S, S is the suffix.
122 public $street_number_postdirectional;
125 * Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200
132 * Supplemental Address Information, Line 1
136 public $supplemental_address_1;
139 * Supplemental Address Information, Line 2
143 public $supplemental_address_2;
146 * Supplemental Address Information, Line 3
150 public $supplemental_address_3;
153 * City, Town or Village Name.
160 * Which County does this address belong to.
167 * Which State_Province does this address belong to.
171 public $state_province_id;
174 * Store the suffix, like the +4 part in the USPS system.
178 public $postal_code_suffix;
181 * Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.
188 * USPS Bulk mailing code.
195 * Which Country does this address belong to.
216 * Is this a manually entered geo code
220 public $manual_geo_code;
223 * Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".
244 public function __construct() {
245 $this->__table
= 'civicrm_address';
246 parent
::__construct();
250 * Returns localized title of this entity.
252 public static function getEntityTitle() {
253 return ts('Addresses');
257 * Returns foreign keys and entity references.
260 * [CRM_Core_Reference_Interface]
262 public static function getReferenceColumns() {
263 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
264 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
265 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
266 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'county_id', 'civicrm_county', 'id');
267 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'state_province_id', 'civicrm_state_province', 'id');
268 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'country_id', 'civicrm_country', 'id');
269 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'master_id', 'civicrm_address', 'id');
270 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
272 return Civi
::$statics[__CLASS__
]['links'];
276 * Returns all the column names of this table
280 public static function &fields() {
281 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
282 Civi
::$statics[__CLASS__
]['fields'] = [
285 'type' => CRM_Utils_Type
::T_INT
,
286 'title' => ts('Address ID'),
287 'description' => ts('Unique Address ID'),
289 'where' => 'civicrm_address.id',
291 'table_name' => 'civicrm_address',
292 'entity' => 'Address',
293 'bao' => 'CRM_Core_BAO_Address',
297 'name' => 'contact_id',
298 'type' => CRM_Utils_Type
::T_INT
,
299 'title' => ts('Contact ID'),
300 'description' => ts('FK to Contact ID'),
301 'where' => 'civicrm_address.contact_id',
302 'table_name' => 'civicrm_address',
303 'entity' => 'Address',
304 'bao' => 'CRM_Core_BAO_Address',
306 'FKClassName' => 'CRM_Contact_DAO_Contact',
308 'location_type_id' => [
309 'name' => 'location_type_id',
310 'type' => CRM_Utils_Type
::T_INT
,
311 'title' => ts('Address Location Type'),
312 'description' => ts('Which Location does this address belong to.'),
313 'where' => 'civicrm_address.location_type_id',
314 'table_name' => 'civicrm_address',
315 'entity' => 'Address',
316 'bao' => 'CRM_Core_BAO_Address',
321 'pseudoconstant' => [
322 'table' => 'civicrm_location_type',
324 'labelColumn' => 'display_name',
328 'name' => 'is_primary',
329 'type' => CRM_Utils_Type
::T_BOOLEAN
,
330 'title' => ts('Primary address'),
331 'description' => ts('Is this the primary address.'),
332 'where' => 'civicrm_address.is_primary',
334 'table_name' => 'civicrm_address',
335 'entity' => 'Address',
336 'bao' => 'CRM_Core_BAO_Address',
343 'name' => 'is_billing',
344 'type' => CRM_Utils_Type
::T_BOOLEAN
,
345 'title' => ts('Is Billing Address'),
346 'description' => ts('Is this the billing address.'),
347 'where' => 'civicrm_address.is_billing',
349 'table_name' => 'civicrm_address',
350 'entity' => 'Address',
351 'bao' => 'CRM_Core_BAO_Address',
354 'type' => 'CheckBox',
357 'street_address' => [
358 'name' => 'street_address',
359 'type' => CRM_Utils_Type
::T_STRING
,
360 'title' => ts('Street Address'),
361 'description' => ts('Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
362 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
365 'size' => CRM_Utils_Type
::HUGE
,
367 'where' => 'civicrm_address.street_address',
368 'headerPattern' => '/(street|address)/i',
369 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i',
371 'table_name' => 'civicrm_address',
372 'entity' => 'Address',
373 'bao' => 'CRM_Core_BAO_Address',
380 'name' => 'street_number',
381 'type' => CRM_Utils_Type
::T_INT
,
382 'title' => ts('Street Number'),
383 'description' => ts('Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.'),
384 'where' => 'civicrm_address.street_number',
386 'table_name' => 'civicrm_address',
387 'entity' => 'Address',
388 'bao' => 'CRM_Core_BAO_Address',
394 'street_number_suffix' => [
395 'name' => 'street_number_suffix',
396 'type' => CRM_Utils_Type
::T_STRING
,
397 'title' => ts('Street Number Suffix'),
398 'description' => ts('Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A'),
400 'size' => CRM_Utils_Type
::EIGHT
,
401 'where' => 'civicrm_address.street_number_suffix',
403 'table_name' => 'civicrm_address',
404 'entity' => 'Address',
405 'bao' => 'CRM_Core_BAO_Address',
411 'street_number_predirectional' => [
412 'name' => 'street_number_predirectional',
413 'type' => CRM_Utils_Type
::T_STRING
,
414 'title' => ts('Street Direction Prefix'),
415 'description' => ts('Directional prefix, e.g. SE Main St, SE is the prefix.'),
417 'size' => CRM_Utils_Type
::EIGHT
,
418 'where' => 'civicrm_address.street_number_predirectional',
419 'table_name' => 'civicrm_address',
420 'entity' => 'Address',
421 'bao' => 'CRM_Core_BAO_Address',
428 'name' => 'street_name',
429 'type' => CRM_Utils_Type
::T_STRING
,
430 'title' => ts('Street Name'),
431 'description' => ts('Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.'),
433 'size' => CRM_Utils_Type
::BIG
,
434 'where' => 'civicrm_address.street_name',
436 'table_name' => 'civicrm_address',
437 'entity' => 'Address',
438 'bao' => 'CRM_Core_BAO_Address',
445 'name' => 'street_type',
446 'type' => CRM_Utils_Type
::T_STRING
,
447 'title' => ts('Street Type'),
448 'description' => ts('St, Rd, Dr, etc.'),
450 'size' => CRM_Utils_Type
::EIGHT
,
451 'where' => 'civicrm_address.street_type',
452 'table_name' => 'civicrm_address',
453 'entity' => 'Address',
454 'bao' => 'CRM_Core_BAO_Address',
460 'street_number_postdirectional' => [
461 'name' => 'street_number_postdirectional',
462 'type' => CRM_Utils_Type
::T_STRING
,
463 'title' => ts('Street Direction Suffix'),
464 'description' => ts('Directional prefix, e.g. Main St S, S is the suffix.'),
466 'size' => CRM_Utils_Type
::EIGHT
,
467 'where' => 'civicrm_address.street_number_postdirectional',
468 'table_name' => 'civicrm_address',
469 'entity' => 'Address',
470 'bao' => 'CRM_Core_BAO_Address',
477 'name' => 'street_unit',
478 'type' => CRM_Utils_Type
::T_STRING
,
479 'title' => ts('Street Unit'),
480 'description' => ts('Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200'),
482 'size' => CRM_Utils_Type
::TWELVE
,
483 'where' => 'civicrm_address.street_unit',
485 'table_name' => 'civicrm_address',
486 'entity' => 'Address',
487 'bao' => 'CRM_Core_BAO_Address',
493 'supplemental_address_1' => [
494 'name' => 'supplemental_address_1',
495 'type' => CRM_Utils_Type
::T_STRING
,
496 'title' => ts('Supplemental Address 1'),
497 'description' => ts('Supplemental Address Information, Line 1'),
499 'size' => CRM_Utils_Type
::HUGE
,
501 'where' => 'civicrm_address.supplemental_address_1',
502 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
503 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
505 'table_name' => 'civicrm_address',
506 'entity' => 'Address',
507 'bao' => 'CRM_Core_BAO_Address',
513 'supplemental_address_2' => [
514 'name' => 'supplemental_address_2',
515 'type' => CRM_Utils_Type
::T_STRING
,
516 'title' => ts('Supplemental Address 2'),
517 'description' => ts('Supplemental Address Information, Line 2'),
519 'size' => CRM_Utils_Type
::HUGE
,
521 'where' => 'civicrm_address.supplemental_address_2',
522 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
523 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
525 'table_name' => 'civicrm_address',
526 'entity' => 'Address',
527 'bao' => 'CRM_Core_BAO_Address',
533 'supplemental_address_3' => [
534 'name' => 'supplemental_address_3',
535 'type' => CRM_Utils_Type
::T_STRING
,
536 'title' => ts('Supplemental Address 3'),
537 'description' => ts('Supplemental Address Information, Line 3'),
539 'size' => CRM_Utils_Type
::HUGE
,
541 'where' => 'civicrm_address.supplemental_address_3',
542 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
543 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
545 'table_name' => 'civicrm_address',
546 'entity' => 'Address',
547 'bao' => 'CRM_Core_BAO_Address',
555 'type' => CRM_Utils_Type
::T_STRING
,
556 'title' => ts('City'),
557 'description' => ts('City, Town or Village Name.'),
559 'size' => CRM_Utils_Type
::BIG
,
561 'where' => 'civicrm_address.city',
562 'headerPattern' => '/city/i',
563 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/',
565 'table_name' => 'civicrm_address',
566 'entity' => 'Address',
567 'bao' => 'CRM_Core_BAO_Address',
574 'name' => 'county_id',
575 'type' => CRM_Utils_Type
::T_INT
,
576 'title' => ts('County'),
577 'description' => ts('Which County does this address belong to.'),
578 'where' => 'civicrm_address.county_id',
579 'table_name' => 'civicrm_address',
580 'entity' => 'Address',
581 'bao' => 'CRM_Core_BAO_Address',
583 'FKClassName' => 'CRM_Core_DAO_County',
585 'type' => 'ChainSelect',
586 'controlField' => 'state_province_id',
588 'pseudoconstant' => [
589 'table' => 'civicrm_county',
591 'labelColumn' => 'name',
594 'state_province_id' => [
595 'name' => 'state_province_id',
596 'type' => CRM_Utils_Type
::T_INT
,
597 'title' => ts('State/Province'),
598 'description' => ts('Which State_Province does this address belong to.'),
599 'where' => 'civicrm_address.state_province_id',
600 'table_name' => 'civicrm_address',
601 'entity' => 'Address',
602 'bao' => 'CRM_Core_BAO_Address',
604 'localize_context' => 'province',
605 'FKClassName' => 'CRM_Core_DAO_StateProvince',
607 'type' => 'ChainSelect',
608 'controlField' => 'country_id',
610 'pseudoconstant' => [
611 'table' => 'civicrm_state_province',
613 'labelColumn' => 'name',
616 'postal_code_suffix' => [
617 'name' => 'postal_code_suffix',
618 'type' => CRM_Utils_Type
::T_STRING
,
619 'title' => ts('Postal Code Suffix'),
620 'description' => ts('Store the suffix, like the +4 part in the USPS system.'),
624 'where' => 'civicrm_address.postal_code_suffix',
625 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
626 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
628 'table_name' => 'civicrm_address',
629 'entity' => 'Address',
630 'bao' => 'CRM_Core_BAO_Address',
637 'name' => 'postal_code',
638 'type' => CRM_Utils_Type
::T_STRING
,
639 'title' => ts('Postal Code'),
640 'description' => ts('Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.'),
644 'where' => 'civicrm_address.postal_code',
645 'headerPattern' => '/postal|zip/i',
646 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
648 'table_name' => 'civicrm_address',
649 'entity' => 'Address',
650 'bao' => 'CRM_Core_BAO_Address',
657 'name' => 'usps_adc',
658 'type' => CRM_Utils_Type
::T_STRING
,
659 'title' => ts('USPS Code'),
660 'description' => ts('USPS Bulk mailing code.'),
662 'size' => CRM_Utils_Type
::MEDIUM
,
663 'where' => 'civicrm_address.usps_adc',
664 'table_name' => 'civicrm_address',
665 'entity' => 'Address',
666 'bao' => 'CRM_Core_BAO_Address',
670 'name' => 'country_id',
671 'type' => CRM_Utils_Type
::T_INT
,
672 'title' => ts('Country'),
673 'description' => ts('Which Country does this address belong to.'),
674 'where' => 'civicrm_address.country_id',
675 'table_name' => 'civicrm_address',
676 'entity' => 'Address',
677 'bao' => 'CRM_Core_BAO_Address',
679 'localize_context' => 'country',
680 'FKClassName' => 'CRM_Core_DAO_Country',
684 'pseudoconstant' => [
685 'table' => 'civicrm_country',
687 'labelColumn' => 'name',
688 'nameColumn' => 'iso_code',
689 'abbrColumn' => 'iso_code',
693 'name' => 'geo_code_1',
694 'type' => CRM_Utils_Type
::T_FLOAT
,
695 'title' => ts('Latitude'),
696 'description' => ts('Latitude'),
698 'where' => 'civicrm_address.geo_code_1',
699 'headerPattern' => '/geo/i',
701 'table_name' => 'civicrm_address',
702 'entity' => 'Address',
703 'bao' => 'CRM_Core_BAO_Address',
710 'name' => 'geo_code_2',
711 'type' => CRM_Utils_Type
::T_FLOAT
,
712 'title' => ts('Longitude'),
713 'description' => ts('Longitude'),
715 'where' => 'civicrm_address.geo_code_2',
716 'headerPattern' => '/geo/i',
718 'table_name' => 'civicrm_address',
719 'entity' => 'Address',
720 'bao' => 'CRM_Core_BAO_Address',
726 'manual_geo_code' => [
727 'name' => 'manual_geo_code',
728 'type' => CRM_Utils_Type
::T_BOOLEAN
,
729 'title' => ts('Is Manually Geocoded'),
730 'description' => ts('Is this a manually entered geo code'),
731 'where' => 'civicrm_address.manual_geo_code',
734 'table_name' => 'civicrm_address',
735 'entity' => 'Address',
736 'bao' => 'CRM_Core_BAO_Address',
739 'type' => 'CheckBox',
743 'name' => 'timezone',
744 'type' => CRM_Utils_Type
::T_STRING
,
745 'title' => ts('Timezone'),
746 'description' => ts('Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".'),
748 'size' => CRM_Utils_Type
::EIGHT
,
749 'where' => 'civicrm_address.timezone',
750 'table_name' => 'civicrm_address',
751 'entity' => 'Address',
752 'bao' => 'CRM_Core_BAO_Address',
760 'type' => CRM_Utils_Type
::T_STRING
,
761 'title' => ts('Address Name'),
763 'size' => CRM_Utils_Type
::HUGE
,
765 'where' => 'civicrm_address.name',
766 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
767 'dataPattern' => '/^\w+$/',
769 'table_name' => 'civicrm_address',
770 'entity' => 'Address',
771 'bao' => 'CRM_Core_BAO_Address',
778 'name' => 'master_id',
779 'type' => CRM_Utils_Type
::T_INT
,
780 'title' => ts('Master Address Belongs To'),
781 'description' => ts('FK to Address ID'),
783 'where' => 'civicrm_address.master_id',
785 'table_name' => 'civicrm_address',
786 'entity' => 'Address',
787 'bao' => 'CRM_Core_BAO_Address',
789 'FKClassName' => 'CRM_Core_DAO_Address',
792 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
794 return Civi
::$statics[__CLASS__
]['fields'];
798 * Return a mapping from field-name to the corresponding key (as used in fields()).
801 * Array(string $name => string $uniqueName).
803 public static function &fieldKeys() {
804 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
805 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
807 return Civi
::$statics[__CLASS__
]['fieldKeys'];
811 * Returns the names of this table
815 public static function getTableName() {
816 return self
::$_tableName;
820 * Returns if this table needs to be logged
824 public function getLog() {
829 * Returns the list of fields that can be imported
831 * @param bool $prefix
835 public static function &import($prefix = FALSE) {
836 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'address', $prefix, [
837 'CRM_Core_DAO_County',
838 'CRM_Core_DAO_StateProvince',
839 'CRM_Core_DAO_Country',
845 * Returns the list of fields that can be exported
847 * @param bool $prefix
851 public static function &export($prefix = FALSE) {
852 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'address', $prefix, [
853 'CRM_Core_DAO_County',
854 'CRM_Core_DAO_StateProvince',
855 'CRM_Core_DAO_Country',
861 * Returns the list of indices
863 * @param bool $localize
867 public static function indices($localize = TRUE) {
869 'index_location_type' => [
870 'name' => 'index_location_type',
872 0 => 'location_type_id',
874 'localizable' => FALSE,
875 'sig' => 'civicrm_address::0::location_type_id',
877 'index_is_primary' => [
878 'name' => 'index_is_primary',
882 'localizable' => FALSE,
883 'sig' => 'civicrm_address::0::is_primary',
885 'index_is_billing' => [
886 'name' => 'index_is_billing',
890 'localizable' => FALSE,
891 'sig' => 'civicrm_address::0::is_billing',
893 'index_street_name' => [
894 'name' => 'index_street_name',
898 'localizable' => FALSE,
899 'sig' => 'civicrm_address::0::street_name',
902 'name' => 'index_city',
906 'localizable' => FALSE,
907 'sig' => 'civicrm_address::0::city',
909 'index_geo_code_1_geo_code_2' => [
910 'name' => 'index_geo_code_1_geo_code_2',
915 'localizable' => FALSE,
916 'sig' => 'civicrm_address::0::geo_code_1::geo_code_2',
919 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;