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:aed8175462599ecc4c8d43887d76350a)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
46 * Which Location does this address belong to.
50 public $location_type_id;
53 * Is this the primary address.
60 * Is this the billing address.
67 * Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
68 * number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
73 public $street_address;
76 * Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.
80 public $street_number;
83 * Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A
87 public $street_number_suffix;
90 * Directional prefix, e.g. SE Main St, SE is the prefix.
94 public $street_number_predirectional;
97 * Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.
111 * Directional prefix, e.g. Main St S, S is the suffix.
115 public $street_number_postdirectional;
118 * Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200
125 * Supplemental Address Information, Line 1
129 public $supplemental_address_1;
132 * Supplemental Address Information, Line 2
136 public $supplemental_address_2;
139 * Supplemental Address Information, Line 3
143 public $supplemental_address_3;
146 * City, Town or Village Name.
153 * Which County does this address belong to.
160 * Which State_Province does this address belong to.
164 public $state_province_id;
167 * Store the suffix, like the +4 part in the USPS system.
171 public $postal_code_suffix;
174 * Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.
181 * USPS Bulk mailing code.
188 * Which Country does this address belong to.
209 * Is this a manually entered geo code
213 public $manual_geo_code;
216 * Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".
237 public function __construct() {
238 $this->__table
= 'civicrm_address';
239 parent
::__construct();
243 * Returns foreign keys and entity references.
246 * [CRM_Core_Reference_Interface]
248 public static function getReferenceColumns() {
249 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
250 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
251 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
252 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'county_id', 'civicrm_county', 'id');
253 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'state_province_id', 'civicrm_state_province', 'id');
254 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'country_id', 'civicrm_country', 'id');
255 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'master_id', 'civicrm_address', 'id');
256 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
258 return Civi
::$statics[__CLASS__
]['links'];
262 * Returns all the column names of this table
266 public static function &fields() {
267 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
268 Civi
::$statics[__CLASS__
]['fields'] = [
271 'type' => CRM_Utils_Type
::T_INT
,
272 'title' => ts('Address ID'),
273 'description' => ts('Unique Address ID'),
275 'where' => 'civicrm_address.id',
277 'table_name' => 'civicrm_address',
278 'entity' => 'Address',
279 'bao' => 'CRM_Core_BAO_Address',
283 'name' => 'contact_id',
284 'type' => CRM_Utils_Type
::T_INT
,
285 'title' => ts('Contact ID'),
286 'description' => ts('FK to Contact ID'),
287 'where' => 'civicrm_address.contact_id',
288 'table_name' => 'civicrm_address',
289 'entity' => 'Address',
290 'bao' => 'CRM_Core_BAO_Address',
292 'FKClassName' => 'CRM_Contact_DAO_Contact',
294 'location_type_id' => [
295 'name' => 'location_type_id',
296 'type' => CRM_Utils_Type
::T_INT
,
297 'title' => ts('Address Location Type'),
298 'description' => ts('Which Location does this address belong to.'),
299 'where' => 'civicrm_address.location_type_id',
300 'table_name' => 'civicrm_address',
301 'entity' => 'Address',
302 'bao' => 'CRM_Core_BAO_Address',
307 'pseudoconstant' => [
308 'table' => 'civicrm_location_type',
310 'labelColumn' => 'display_name',
314 'name' => 'is_primary',
315 'type' => CRM_Utils_Type
::T_BOOLEAN
,
316 'title' => ts('Primary address'),
317 'description' => ts('Is this the primary address.'),
318 'where' => 'civicrm_address.is_primary',
320 'table_name' => 'civicrm_address',
321 'entity' => 'Address',
322 'bao' => 'CRM_Core_BAO_Address',
329 'name' => 'is_billing',
330 'type' => CRM_Utils_Type
::T_BOOLEAN
,
331 'title' => ts('Is Billing Address'),
332 'description' => ts('Is this the billing address.'),
333 'where' => 'civicrm_address.is_billing',
335 'table_name' => 'civicrm_address',
336 'entity' => 'Address',
337 'bao' => 'CRM_Core_BAO_Address',
340 'type' => 'CheckBox',
343 'street_address' => [
344 'name' => 'street_address',
345 'type' => CRM_Utils_Type
::T_STRING
,
346 'title' => ts('Street Address'),
347 'description' => ts('Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
348 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
351 'size' => CRM_Utils_Type
::HUGE
,
353 'where' => 'civicrm_address.street_address',
354 'headerPattern' => '/(street|address)/i',
355 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i',
357 'table_name' => 'civicrm_address',
358 'entity' => 'Address',
359 'bao' => 'CRM_Core_BAO_Address',
366 'name' => 'street_number',
367 'type' => CRM_Utils_Type
::T_INT
,
368 'title' => ts('Street Number'),
369 'description' => ts('Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.'),
370 'where' => 'civicrm_address.street_number',
372 'table_name' => 'civicrm_address',
373 'entity' => 'Address',
374 'bao' => 'CRM_Core_BAO_Address',
380 'street_number_suffix' => [
381 'name' => 'street_number_suffix',
382 'type' => CRM_Utils_Type
::T_STRING
,
383 'title' => ts('Street Number Suffix'),
384 'description' => ts('Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A'),
386 'size' => CRM_Utils_Type
::EIGHT
,
387 'where' => 'civicrm_address.street_number_suffix',
389 'table_name' => 'civicrm_address',
390 'entity' => 'Address',
391 'bao' => 'CRM_Core_BAO_Address',
397 'street_number_predirectional' => [
398 'name' => 'street_number_predirectional',
399 'type' => CRM_Utils_Type
::T_STRING
,
400 'title' => ts('Street Direction Prefix'),
401 'description' => ts('Directional prefix, e.g. SE Main St, SE is the prefix.'),
403 'size' => CRM_Utils_Type
::EIGHT
,
404 'where' => 'civicrm_address.street_number_predirectional',
405 'table_name' => 'civicrm_address',
406 'entity' => 'Address',
407 'bao' => 'CRM_Core_BAO_Address',
414 'name' => 'street_name',
415 'type' => CRM_Utils_Type
::T_STRING
,
416 'title' => ts('Street Name'),
417 'description' => ts('Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.'),
419 'size' => CRM_Utils_Type
::BIG
,
420 'where' => 'civicrm_address.street_name',
422 'table_name' => 'civicrm_address',
423 'entity' => 'Address',
424 'bao' => 'CRM_Core_BAO_Address',
431 'name' => 'street_type',
432 'type' => CRM_Utils_Type
::T_STRING
,
433 'title' => ts('Street Type'),
434 'description' => ts('St, Rd, Dr, etc.'),
436 'size' => CRM_Utils_Type
::EIGHT
,
437 'where' => 'civicrm_address.street_type',
438 'table_name' => 'civicrm_address',
439 'entity' => 'Address',
440 'bao' => 'CRM_Core_BAO_Address',
446 'street_number_postdirectional' => [
447 'name' => 'street_number_postdirectional',
448 'type' => CRM_Utils_Type
::T_STRING
,
449 'title' => ts('Street Direction Suffix'),
450 'description' => ts('Directional prefix, e.g. Main St S, S is the suffix.'),
452 'size' => CRM_Utils_Type
::EIGHT
,
453 'where' => 'civicrm_address.street_number_postdirectional',
454 'table_name' => 'civicrm_address',
455 'entity' => 'Address',
456 'bao' => 'CRM_Core_BAO_Address',
463 'name' => 'street_unit',
464 'type' => CRM_Utils_Type
::T_STRING
,
465 'title' => ts('Street Unit'),
466 'description' => ts('Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200'),
468 'size' => CRM_Utils_Type
::TWELVE
,
469 'where' => 'civicrm_address.street_unit',
471 'table_name' => 'civicrm_address',
472 'entity' => 'Address',
473 'bao' => 'CRM_Core_BAO_Address',
479 'supplemental_address_1' => [
480 'name' => 'supplemental_address_1',
481 'type' => CRM_Utils_Type
::T_STRING
,
482 'title' => ts('Supplemental Address 1'),
483 'description' => ts('Supplemental Address Information, Line 1'),
485 'size' => CRM_Utils_Type
::HUGE
,
487 'where' => 'civicrm_address.supplemental_address_1',
488 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
489 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
491 'table_name' => 'civicrm_address',
492 'entity' => 'Address',
493 'bao' => 'CRM_Core_BAO_Address',
499 'supplemental_address_2' => [
500 'name' => 'supplemental_address_2',
501 'type' => CRM_Utils_Type
::T_STRING
,
502 'title' => ts('Supplemental Address 2'),
503 'description' => ts('Supplemental Address Information, Line 2'),
505 'size' => CRM_Utils_Type
::HUGE
,
507 'where' => 'civicrm_address.supplemental_address_2',
508 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
509 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
511 'table_name' => 'civicrm_address',
512 'entity' => 'Address',
513 'bao' => 'CRM_Core_BAO_Address',
519 'supplemental_address_3' => [
520 'name' => 'supplemental_address_3',
521 'type' => CRM_Utils_Type
::T_STRING
,
522 'title' => ts('Supplemental Address 3'),
523 'description' => ts('Supplemental Address Information, Line 3'),
525 'size' => CRM_Utils_Type
::HUGE
,
527 'where' => 'civicrm_address.supplemental_address_3',
528 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
529 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
531 'table_name' => 'civicrm_address',
532 'entity' => 'Address',
533 'bao' => 'CRM_Core_BAO_Address',
541 'type' => CRM_Utils_Type
::T_STRING
,
542 'title' => ts('City'),
543 'description' => ts('City, Town or Village Name.'),
545 'size' => CRM_Utils_Type
::BIG
,
547 'where' => 'civicrm_address.city',
548 'headerPattern' => '/city/i',
549 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/',
551 'table_name' => 'civicrm_address',
552 'entity' => 'Address',
553 'bao' => 'CRM_Core_BAO_Address',
560 'name' => 'county_id',
561 'type' => CRM_Utils_Type
::T_INT
,
562 'title' => ts('County'),
563 'description' => ts('Which County does this address belong to.'),
564 'where' => 'civicrm_address.county_id',
565 'table_name' => 'civicrm_address',
566 'entity' => 'Address',
567 'bao' => 'CRM_Core_BAO_Address',
569 'FKClassName' => 'CRM_Core_DAO_County',
571 'type' => 'ChainSelect',
572 'controlField' => 'state_province_id',
574 'pseudoconstant' => [
575 'table' => 'civicrm_county',
577 'labelColumn' => 'name',
580 'state_province_id' => [
581 'name' => 'state_province_id',
582 'type' => CRM_Utils_Type
::T_INT
,
583 'title' => ts('State/Province'),
584 'description' => ts('Which State_Province does this address belong to.'),
585 'where' => 'civicrm_address.state_province_id',
586 'table_name' => 'civicrm_address',
587 'entity' => 'Address',
588 'bao' => 'CRM_Core_BAO_Address',
590 'localize_context' => 'province',
591 'FKClassName' => 'CRM_Core_DAO_StateProvince',
593 'type' => 'ChainSelect',
594 'controlField' => 'country_id',
596 'pseudoconstant' => [
597 'table' => 'civicrm_state_province',
599 'labelColumn' => 'name',
602 'postal_code_suffix' => [
603 'name' => 'postal_code_suffix',
604 'type' => CRM_Utils_Type
::T_STRING
,
605 'title' => ts('Postal Code Suffix'),
606 'description' => ts('Store the suffix, like the +4 part in the USPS system.'),
610 'where' => 'civicrm_address.postal_code_suffix',
611 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
612 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
614 'table_name' => 'civicrm_address',
615 'entity' => 'Address',
616 'bao' => 'CRM_Core_BAO_Address',
623 'name' => 'postal_code',
624 'type' => CRM_Utils_Type
::T_STRING
,
625 'title' => ts('Postal Code'),
626 'description' => ts('Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.'),
630 'where' => 'civicrm_address.postal_code',
631 'headerPattern' => '/postal|zip/i',
632 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
634 'table_name' => 'civicrm_address',
635 'entity' => 'Address',
636 'bao' => 'CRM_Core_BAO_Address',
643 'name' => 'usps_adc',
644 'type' => CRM_Utils_Type
::T_STRING
,
645 'title' => ts('USPS Code'),
646 'description' => ts('USPS Bulk mailing code.'),
648 'size' => CRM_Utils_Type
::MEDIUM
,
649 'where' => 'civicrm_address.usps_adc',
650 'table_name' => 'civicrm_address',
651 'entity' => 'Address',
652 'bao' => 'CRM_Core_BAO_Address',
656 'name' => 'country_id',
657 'type' => CRM_Utils_Type
::T_INT
,
658 'title' => ts('Country'),
659 'description' => ts('Which Country does this address belong to.'),
660 'where' => 'civicrm_address.country_id',
661 'table_name' => 'civicrm_address',
662 'entity' => 'Address',
663 'bao' => 'CRM_Core_BAO_Address',
665 'localize_context' => 'country',
666 'FKClassName' => 'CRM_Core_DAO_Country',
670 'pseudoconstant' => [
671 'table' => 'civicrm_country',
673 'labelColumn' => 'name',
674 'nameColumn' => 'iso_code',
675 'abbrColumn' => 'iso_code',
679 'name' => 'geo_code_1',
680 'type' => CRM_Utils_Type
::T_FLOAT
,
681 'title' => ts('Latitude'),
682 'description' => ts('Latitude'),
684 'where' => 'civicrm_address.geo_code_1',
685 'headerPattern' => '/geo/i',
687 'table_name' => 'civicrm_address',
688 'entity' => 'Address',
689 'bao' => 'CRM_Core_BAO_Address',
696 'name' => 'geo_code_2',
697 'type' => CRM_Utils_Type
::T_FLOAT
,
698 'title' => ts('Longitude'),
699 'description' => ts('Longitude'),
701 'where' => 'civicrm_address.geo_code_2',
702 'headerPattern' => '/geo/i',
704 'table_name' => 'civicrm_address',
705 'entity' => 'Address',
706 'bao' => 'CRM_Core_BAO_Address',
712 'manual_geo_code' => [
713 'name' => 'manual_geo_code',
714 'type' => CRM_Utils_Type
::T_BOOLEAN
,
715 'title' => ts('Is Manually Geocoded'),
716 'description' => ts('Is this a manually entered geo code'),
717 'where' => 'civicrm_address.manual_geo_code',
720 'table_name' => 'civicrm_address',
721 'entity' => 'Address',
722 'bao' => 'CRM_Core_BAO_Address',
725 'type' => 'CheckBox',
729 'name' => 'timezone',
730 'type' => CRM_Utils_Type
::T_STRING
,
731 'title' => ts('Timezone'),
732 'description' => ts('Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".'),
734 'size' => CRM_Utils_Type
::EIGHT
,
735 'where' => 'civicrm_address.timezone',
736 'table_name' => 'civicrm_address',
737 'entity' => 'Address',
738 'bao' => 'CRM_Core_BAO_Address',
746 'type' => CRM_Utils_Type
::T_STRING
,
747 'title' => ts('Address Name'),
749 'size' => CRM_Utils_Type
::HUGE
,
751 'where' => 'civicrm_address.name',
752 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
753 'dataPattern' => '/^\w+$/',
755 'table_name' => 'civicrm_address',
756 'entity' => 'Address',
757 'bao' => 'CRM_Core_BAO_Address',
764 'name' => 'master_id',
765 'type' => CRM_Utils_Type
::T_INT
,
766 'title' => ts('Master Address Belongs To'),
767 'description' => ts('FK to Address ID'),
769 'where' => 'civicrm_address.master_id',
771 'table_name' => 'civicrm_address',
772 'entity' => 'Address',
773 'bao' => 'CRM_Core_BAO_Address',
775 'FKClassName' => 'CRM_Core_DAO_Address',
778 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
780 return Civi
::$statics[__CLASS__
]['fields'];
784 * Return a mapping from field-name to the corresponding key (as used in fields()).
787 * Array(string $name => string $uniqueName).
789 public static function &fieldKeys() {
790 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
791 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
793 return Civi
::$statics[__CLASS__
]['fieldKeys'];
797 * Returns the names of this table
801 public static function getTableName() {
802 return self
::$_tableName;
806 * Returns if this table needs to be logged
810 public function getLog() {
815 * Returns the list of fields that can be imported
817 * @param bool $prefix
821 public static function &import($prefix = FALSE) {
822 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'address', $prefix, [
823 'CRM_Core_DAO_County',
824 'CRM_Core_DAO_StateProvince',
825 'CRM_Core_DAO_Country',
831 * Returns the list of fields that can be exported
833 * @param bool $prefix
837 public static function &export($prefix = FALSE) {
838 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'address', $prefix, [
839 'CRM_Core_DAO_County',
840 'CRM_Core_DAO_StateProvince',
841 'CRM_Core_DAO_Country',
847 * Returns the list of indices
849 * @param bool $localize
853 public static function indices($localize = TRUE) {
855 'index_location_type' => [
856 'name' => 'index_location_type',
858 0 => 'location_type_id',
860 'localizable' => FALSE,
861 'sig' => 'civicrm_address::0::location_type_id',
863 'index_is_primary' => [
864 'name' => 'index_is_primary',
868 'localizable' => FALSE,
869 'sig' => 'civicrm_address::0::is_primary',
871 'index_is_billing' => [
872 'name' => 'index_is_billing',
876 'localizable' => FALSE,
877 'sig' => 'civicrm_address::0::is_billing',
879 'index_street_name' => [
880 'name' => 'index_street_name',
884 'localizable' => FALSE,
885 'sig' => 'civicrm_address::0::street_name',
888 'name' => 'index_city',
892 'localizable' => FALSE,
893 'sig' => 'civicrm_address::0::city',
895 'index_geo_code_1_geo_code_2' => [
896 'name' => 'index_geo_code_1_geo_code_2',
901 'localizable' => FALSE,
902 'sig' => 'civicrm_address::0::geo_code_1::geo_code_2',
905 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;