5 * @copyright CiviCRM LLC (c) 2004-2019
7 * Generated from xml/schema/CRM/Core/Address.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:4999e79688aae8d0958e46cbd320ae3a)
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',
276 'table_name' => 'civicrm_address',
277 'entity' => 'Address',
278 'bao' => 'CRM_Core_BAO_Address',
282 'name' => 'contact_id',
283 'type' => CRM_Utils_Type
::T_INT
,
284 'title' => ts('Contact ID'),
285 'description' => ts('FK to Contact ID'),
286 'where' => 'civicrm_address.contact_id',
287 'table_name' => 'civicrm_address',
288 'entity' => 'Address',
289 'bao' => 'CRM_Core_BAO_Address',
291 'FKClassName' => 'CRM_Contact_DAO_Contact',
293 'location_type_id' => [
294 'name' => 'location_type_id',
295 'type' => CRM_Utils_Type
::T_INT
,
296 'title' => ts('Address Location Type'),
297 'description' => ts('Which Location does this address belong to.'),
298 'where' => 'civicrm_address.location_type_id',
299 'table_name' => 'civicrm_address',
300 'entity' => 'Address',
301 'bao' => 'CRM_Core_BAO_Address',
306 'pseudoconstant' => [
307 'table' => 'civicrm_location_type',
309 'labelColumn' => 'display_name',
313 'name' => 'is_primary',
314 'type' => CRM_Utils_Type
::T_BOOLEAN
,
315 'title' => ts('Is Address Primary?'),
316 'description' => ts('Is this the primary address.'),
317 'where' => 'civicrm_address.is_primary',
319 'table_name' => 'civicrm_address',
320 'entity' => 'Address',
321 'bao' => 'CRM_Core_BAO_Address',
324 'type' => 'CheckBox',
328 'name' => 'is_billing',
329 'type' => CRM_Utils_Type
::T_BOOLEAN
,
330 'title' => ts('Is Billing Address'),
331 'description' => ts('Is this the billing address.'),
332 'where' => 'civicrm_address.is_billing',
334 'table_name' => 'civicrm_address',
335 'entity' => 'Address',
336 'bao' => 'CRM_Core_BAO_Address',
339 'type' => 'CheckBox',
342 'street_address' => [
343 'name' => 'street_address',
344 'type' => CRM_Utils_Type
::T_STRING
,
345 'title' => ts('Street Address'),
346 'description' => ts('Concatenation of all routable street address components (prefix, street number, street name, suffix, unit
347 number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail
350 'size' => CRM_Utils_Type
::HUGE
,
352 'where' => 'civicrm_address.street_address',
353 'headerPattern' => '/(street|address)/i',
354 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i',
356 'table_name' => 'civicrm_address',
357 'entity' => 'Address',
358 'bao' => 'CRM_Core_BAO_Address',
365 'name' => 'street_number',
366 'type' => CRM_Utils_Type
::T_INT
,
367 'title' => ts('Street Number'),
368 'description' => ts('Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.'),
369 'where' => 'civicrm_address.street_number',
371 'table_name' => 'civicrm_address',
372 'entity' => 'Address',
373 'bao' => 'CRM_Core_BAO_Address',
379 'street_number_suffix' => [
380 'name' => 'street_number_suffix',
381 'type' => CRM_Utils_Type
::T_STRING
,
382 'title' => ts('Street Number Suffix'),
383 'description' => ts('Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A'),
385 'size' => CRM_Utils_Type
::EIGHT
,
386 'where' => 'civicrm_address.street_number_suffix',
388 'table_name' => 'civicrm_address',
389 'entity' => 'Address',
390 'bao' => 'CRM_Core_BAO_Address',
396 'street_number_predirectional' => [
397 'name' => 'street_number_predirectional',
398 'type' => CRM_Utils_Type
::T_STRING
,
399 'title' => ts('Street Direction Prefix'),
400 'description' => ts('Directional prefix, e.g. SE Main St, SE is the prefix.'),
402 'size' => CRM_Utils_Type
::EIGHT
,
403 'where' => 'civicrm_address.street_number_predirectional',
404 'table_name' => 'civicrm_address',
405 'entity' => 'Address',
406 'bao' => 'CRM_Core_BAO_Address',
413 'name' => 'street_name',
414 'type' => CRM_Utils_Type
::T_STRING
,
415 'title' => ts('Street Name'),
416 'description' => ts('Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.'),
418 'size' => CRM_Utils_Type
::BIG
,
419 'where' => 'civicrm_address.street_name',
421 'table_name' => 'civicrm_address',
422 'entity' => 'Address',
423 'bao' => 'CRM_Core_BAO_Address',
430 'name' => 'street_type',
431 'type' => CRM_Utils_Type
::T_STRING
,
432 'title' => ts('Street Type'),
433 'description' => ts('St, Rd, Dr, etc.'),
435 'size' => CRM_Utils_Type
::EIGHT
,
436 'where' => 'civicrm_address.street_type',
437 'table_name' => 'civicrm_address',
438 'entity' => 'Address',
439 'bao' => 'CRM_Core_BAO_Address',
445 'street_number_postdirectional' => [
446 'name' => 'street_number_postdirectional',
447 'type' => CRM_Utils_Type
::T_STRING
,
448 'title' => ts('Street Direction Suffix'),
449 'description' => ts('Directional prefix, e.g. Main St S, S is the suffix.'),
451 'size' => CRM_Utils_Type
::EIGHT
,
452 'where' => 'civicrm_address.street_number_postdirectional',
453 'table_name' => 'civicrm_address',
454 'entity' => 'Address',
455 'bao' => 'CRM_Core_BAO_Address',
462 'name' => 'street_unit',
463 'type' => CRM_Utils_Type
::T_STRING
,
464 'title' => ts('Street Unit'),
465 'description' => ts('Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200'),
467 'size' => CRM_Utils_Type
::TWELVE
,
468 'where' => 'civicrm_address.street_unit',
470 'table_name' => 'civicrm_address',
471 'entity' => 'Address',
472 'bao' => 'CRM_Core_BAO_Address',
478 'supplemental_address_1' => [
479 'name' => 'supplemental_address_1',
480 'type' => CRM_Utils_Type
::T_STRING
,
481 'title' => ts('Supplemental Address 1'),
482 'description' => ts('Supplemental Address Information, Line 1'),
484 'size' => CRM_Utils_Type
::HUGE
,
486 'where' => 'civicrm_address.supplemental_address_1',
487 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
488 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
490 'table_name' => 'civicrm_address',
491 'entity' => 'Address',
492 'bao' => 'CRM_Core_BAO_Address',
498 'supplemental_address_2' => [
499 'name' => 'supplemental_address_2',
500 'type' => CRM_Utils_Type
::T_STRING
,
501 'title' => ts('Supplemental Address 2'),
502 'description' => ts('Supplemental Address Information, Line 2'),
504 'size' => CRM_Utils_Type
::HUGE
,
506 'where' => 'civicrm_address.supplemental_address_2',
507 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
508 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
510 'table_name' => 'civicrm_address',
511 'entity' => 'Address',
512 'bao' => 'CRM_Core_BAO_Address',
518 'supplemental_address_3' => [
519 'name' => 'supplemental_address_3',
520 'type' => CRM_Utils_Type
::T_STRING
,
521 'title' => ts('Supplemental Address 3'),
522 'description' => ts('Supplemental Address Information, Line 3'),
524 'size' => CRM_Utils_Type
::HUGE
,
526 'where' => 'civicrm_address.supplemental_address_3',
527 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i',
528 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i',
530 'table_name' => 'civicrm_address',
531 'entity' => 'Address',
532 'bao' => 'CRM_Core_BAO_Address',
540 'type' => CRM_Utils_Type
::T_STRING
,
541 'title' => ts('City'),
542 'description' => ts('City, Town or Village Name.'),
544 'size' => CRM_Utils_Type
::BIG
,
546 'where' => 'civicrm_address.city',
547 'headerPattern' => '/city/i',
548 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/',
550 'table_name' => 'civicrm_address',
551 'entity' => 'Address',
552 'bao' => 'CRM_Core_BAO_Address',
559 'name' => 'county_id',
560 'type' => CRM_Utils_Type
::T_INT
,
561 'title' => ts('County'),
562 'description' => ts('Which County does this address belong to.'),
563 'where' => 'civicrm_address.county_id',
564 'table_name' => 'civicrm_address',
565 'entity' => 'Address',
566 'bao' => 'CRM_Core_BAO_Address',
568 'FKClassName' => 'CRM_Core_DAO_County',
570 'type' => 'ChainSelect',
572 'pseudoconstant' => [
573 'table' => 'civicrm_county',
575 'labelColumn' => 'name',
578 'state_province_id' => [
579 'name' => 'state_province_id',
580 'type' => CRM_Utils_Type
::T_INT
,
581 'title' => ts('State/Province'),
582 'description' => ts('Which State_Province does this address belong to.'),
583 'where' => 'civicrm_address.state_province_id',
584 'table_name' => 'civicrm_address',
585 'entity' => 'Address',
586 'bao' => 'CRM_Core_BAO_Address',
588 'localize_context' => 'province',
589 'FKClassName' => 'CRM_Core_DAO_StateProvince',
591 'type' => 'ChainSelect',
593 'pseudoconstant' => [
594 'table' => 'civicrm_state_province',
596 'labelColumn' => 'name',
599 'postal_code_suffix' => [
600 'name' => 'postal_code_suffix',
601 'type' => CRM_Utils_Type
::T_STRING
,
602 'title' => ts('Postal Code Suffix'),
603 'description' => ts('Store the suffix, like the +4 part in the USPS system.'),
607 'where' => 'civicrm_address.postal_code_suffix',
608 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i',
609 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
611 'table_name' => 'civicrm_address',
612 'entity' => 'Address',
613 'bao' => 'CRM_Core_BAO_Address',
620 'name' => 'postal_code',
621 'type' => CRM_Utils_Type
::T_STRING
,
622 'title' => ts('Postal Code'),
623 'description' => ts('Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.'),
627 'where' => 'civicrm_address.postal_code',
628 'headerPattern' => '/postal|zip/i',
629 'dataPattern' => '/\d?\d{4}(-\d{4})?/',
631 'table_name' => 'civicrm_address',
632 'entity' => 'Address',
633 'bao' => 'CRM_Core_BAO_Address',
640 'name' => 'usps_adc',
641 'type' => CRM_Utils_Type
::T_STRING
,
642 'title' => ts('USPS Code'),
643 'description' => ts('USPS Bulk mailing code.'),
645 'size' => CRM_Utils_Type
::MEDIUM
,
646 'where' => 'civicrm_address.usps_adc',
647 'table_name' => 'civicrm_address',
648 'entity' => 'Address',
649 'bao' => 'CRM_Core_BAO_Address',
653 'name' => 'country_id',
654 'type' => CRM_Utils_Type
::T_INT
,
655 'title' => ts('Country'),
656 'description' => ts('Which Country does this address belong to.'),
657 'where' => 'civicrm_address.country_id',
658 'table_name' => 'civicrm_address',
659 'entity' => 'Address',
660 'bao' => 'CRM_Core_BAO_Address',
662 'localize_context' => 'country',
663 'FKClassName' => 'CRM_Core_DAO_Country',
667 'pseudoconstant' => [
668 'table' => 'civicrm_country',
670 'labelColumn' => 'name',
671 'nameColumn' => 'iso_code',
675 'name' => 'geo_code_1',
676 'type' => CRM_Utils_Type
::T_FLOAT
,
677 'title' => ts('Latitude'),
678 'description' => ts('Latitude'),
680 'where' => 'civicrm_address.geo_code_1',
681 'headerPattern' => '/geo/i',
683 'table_name' => 'civicrm_address',
684 'entity' => 'Address',
685 'bao' => 'CRM_Core_BAO_Address',
692 'name' => 'geo_code_2',
693 'type' => CRM_Utils_Type
::T_FLOAT
,
694 'title' => ts('Longitude'),
695 'description' => ts('Longitude'),
697 'where' => 'civicrm_address.geo_code_2',
698 'headerPattern' => '/geo/i',
700 'table_name' => 'civicrm_address',
701 'entity' => 'Address',
702 'bao' => 'CRM_Core_BAO_Address',
708 'manual_geo_code' => [
709 'name' => 'manual_geo_code',
710 'type' => CRM_Utils_Type
::T_BOOLEAN
,
711 'title' => ts('Is manually geocoded'),
712 'description' => ts('Is this a manually entered geo code'),
713 'where' => 'civicrm_address.manual_geo_code',
715 'table_name' => 'civicrm_address',
716 'entity' => 'Address',
717 'bao' => 'CRM_Core_BAO_Address',
720 'type' => 'CheckBox',
724 'name' => 'timezone',
725 'type' => CRM_Utils_Type
::T_STRING
,
726 'title' => ts('Timezone'),
727 'description' => ts('Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".'),
729 'size' => CRM_Utils_Type
::EIGHT
,
730 'where' => 'civicrm_address.timezone',
731 'table_name' => 'civicrm_address',
732 'entity' => 'Address',
733 'bao' => 'CRM_Core_BAO_Address',
741 'type' => CRM_Utils_Type
::T_STRING
,
742 'title' => ts('Address Name'),
744 'size' => CRM_Utils_Type
::HUGE
,
746 'where' => 'civicrm_address.name',
747 'headerPattern' => '/^location|(l(ocation\s)?name)$/i',
748 'dataPattern' => '/^\w+$/',
750 'table_name' => 'civicrm_address',
751 'entity' => 'Address',
752 'bao' => 'CRM_Core_BAO_Address',
759 'name' => 'master_id',
760 'type' => CRM_Utils_Type
::T_INT
,
761 'title' => ts('Master Address Belongs To'),
762 'description' => ts('FK to Address ID'),
764 'where' => 'civicrm_address.master_id',
766 'table_name' => 'civicrm_address',
767 'entity' => 'Address',
768 'bao' => 'CRM_Core_BAO_Address',
770 'FKClassName' => 'CRM_Core_DAO_Address',
773 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
775 return Civi
::$statics[__CLASS__
]['fields'];
779 * Return a mapping from field-name to the corresponding key (as used in fields()).
782 * Array(string $name => string $uniqueName).
784 public static function &fieldKeys() {
785 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
786 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
788 return Civi
::$statics[__CLASS__
]['fieldKeys'];
792 * Returns the names of this table
796 public static function getTableName() {
797 return self
::$_tableName;
801 * Returns if this table needs to be logged
805 public function getLog() {
810 * Returns the list of fields that can be imported
812 * @param bool $prefix
816 public static function &import($prefix = FALSE) {
817 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'address', $prefix, [
818 'CRM_Core_DAO_County',
819 'CRM_Core_DAO_StateProvince',
820 'CRM_Core_DAO_Country',
826 * Returns the list of fields that can be exported
828 * @param bool $prefix
832 public static function &export($prefix = FALSE) {
833 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'address', $prefix, [
834 'CRM_Core_DAO_County',
835 'CRM_Core_DAO_StateProvince',
836 'CRM_Core_DAO_Country',
842 * Returns the list of indices
844 * @param bool $localize
848 public static function indices($localize = TRUE) {
850 'index_location_type' => [
851 'name' => 'index_location_type',
853 0 => 'location_type_id',
855 'localizable' => FALSE,
856 'sig' => 'civicrm_address::0::location_type_id',
858 'index_is_primary' => [
859 'name' => 'index_is_primary',
863 'localizable' => FALSE,
864 'sig' => 'civicrm_address::0::is_primary',
866 'index_is_billing' => [
867 'name' => 'index_is_billing',
871 'localizable' => FALSE,
872 'sig' => 'civicrm_address::0::is_billing',
874 'index_street_name' => [
875 'name' => 'index_street_name',
879 'localizable' => FALSE,
880 'sig' => 'civicrm_address::0::street_name',
883 'name' => 'index_city',
887 'localizable' => FALSE,
888 'sig' => 'civicrm_address::0::city',
891 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;