5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/Phone.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:76a7202934e0d8aa7f4240c61a42e42c)
13 * Database access object for the Phone entity.
15 class CRM_Core_DAO_Phone
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_phone';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
46 * Which Location does this phone belong to.
50 public $location_type_id;
53 * Is this the primary phone for this contact and location.
60 * Is this the billing?
67 * Which Mobile Provider does this phone belong to.
71 public $mobile_provider_id;
74 * Complete phone number.
81 * Optional extension for a phone number.
88 * Phone number stripped of all whitespace, letters, and punctuation.
92 public $phone_numeric;
95 * Which type of phone does this number belongs.
99 public $phone_type_id;
104 public function __construct() {
105 $this->__table
= 'civicrm_phone';
106 parent
::__construct();
110 * Returns foreign keys and entity references.
113 * [CRM_Core_Reference_Interface]
115 public static function getReferenceColumns() {
116 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
117 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
118 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
119 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
121 return Civi
::$statics[__CLASS__
]['links'];
125 * Returns all the column names of this table
129 public static function &fields() {
130 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
131 Civi
::$statics[__CLASS__
]['fields'] = [
134 'type' => CRM_Utils_Type
::T_INT
,
135 'title' => ts('Phone ID'),
136 'description' => ts('Unique Phone ID'),
138 'where' => 'civicrm_phone.id',
139 'table_name' => 'civicrm_phone',
141 'bao' => 'CRM_Core_BAO_Phone',
145 'name' => 'contact_id',
146 'type' => CRM_Utils_Type
::T_INT
,
147 'title' => ts('Phone Contact'),
148 'description' => ts('FK to Contact ID'),
149 'where' => 'civicrm_phone.contact_id',
150 'table_name' => 'civicrm_phone',
152 'bao' => 'CRM_Core_BAO_Phone',
154 'FKClassName' => 'CRM_Contact_DAO_Contact',
156 'location_type_id' => [
157 'name' => 'location_type_id',
158 'type' => CRM_Utils_Type
::T_INT
,
159 'title' => ts('Phone Location Type'),
160 'description' => ts('Which Location does this phone belong to.'),
161 'where' => 'civicrm_phone.location_type_id',
162 'table_name' => 'civicrm_phone',
164 'bao' => 'CRM_Core_BAO_Phone',
169 'pseudoconstant' => [
170 'table' => 'civicrm_location_type',
172 'labelColumn' => 'display_name',
176 'name' => 'is_primary',
177 'type' => CRM_Utils_Type
::T_BOOLEAN
,
178 'title' => ts('Primary phone'),
179 'description' => ts('Is this the primary phone for this contact and location.'),
180 'where' => 'civicrm_phone.is_primary',
182 'table_name' => 'civicrm_phone',
184 'bao' => 'CRM_Core_BAO_Phone',
191 'name' => 'is_billing',
192 'type' => CRM_Utils_Type
::T_BOOLEAN
,
193 'title' => ts('Is Billing Phone'),
194 'description' => ts('Is this the billing?'),
195 'where' => 'civicrm_phone.is_billing',
197 'table_name' => 'civicrm_phone',
199 'bao' => 'CRM_Core_BAO_Phone',
202 'mobile_provider_id' => [
203 'name' => 'mobile_provider_id',
204 'type' => CRM_Utils_Type
::T_INT
,
205 'title' => ts('Mobile Provider'),
206 'description' => ts('Which Mobile Provider does this phone belong to.'),
207 'where' => 'civicrm_phone.mobile_provider_id',
208 'table_name' => 'civicrm_phone',
210 'bao' => 'CRM_Core_BAO_Phone',
215 'type' => CRM_Utils_Type
::T_STRING
,
216 'title' => ts('Phone'),
217 'description' => ts('Complete phone number.'),
219 'size' => CRM_Utils_Type
::MEDIUM
,
221 'where' => 'civicrm_phone.phone',
222 'headerPattern' => '/phone/i',
223 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
225 'table_name' => 'civicrm_phone',
227 'bao' => 'CRM_Core_BAO_Phone',
234 'name' => 'phone_ext',
235 'type' => CRM_Utils_Type
::T_STRING
,
236 'title' => ts('Phone Extension'),
237 'description' => ts('Optional extension for a phone number.'),
241 'where' => 'civicrm_phone.phone_ext',
242 'headerPattern' => '/extension/i',
243 'dataPattern' => '/^\d+$/',
245 'table_name' => 'civicrm_phone',
247 'bao' => 'CRM_Core_BAO_Phone',
254 'name' => 'phone_numeric',
255 'type' => CRM_Utils_Type
::T_STRING
,
256 'title' => ts('Phone Numeric'),
257 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
259 'size' => CRM_Utils_Type
::MEDIUM
,
260 'where' => 'civicrm_phone.phone_numeric',
261 'table_name' => 'civicrm_phone',
263 'bao' => 'CRM_Core_BAO_Phone',
267 'name' => 'phone_type_id',
268 'type' => CRM_Utils_Type
::T_INT
,
269 'title' => ts('Phone Type'),
270 'description' => ts('Which type of phone does this number belongs.'),
271 'where' => 'civicrm_phone.phone_type_id',
273 'table_name' => 'civicrm_phone',
275 'bao' => 'CRM_Core_BAO_Phone',
280 'pseudoconstant' => [
281 'optionGroupName' => 'phone_type',
282 'optionEditPath' => 'civicrm/admin/options/phone_type',
286 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
288 return Civi
::$statics[__CLASS__
]['fields'];
292 * Return a mapping from field-name to the corresponding key (as used in fields()).
295 * Array(string $name => string $uniqueName).
297 public static function &fieldKeys() {
298 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
299 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
301 return Civi
::$statics[__CLASS__
]['fieldKeys'];
305 * Returns the names of this table
309 public static function getTableName() {
310 return self
::$_tableName;
314 * Returns if this table needs to be logged
318 public function getLog() {
323 * Returns the list of fields that can be imported
325 * @param bool $prefix
329 public static function &import($prefix = FALSE) {
330 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'phone', $prefix, []);
335 * Returns the list of fields that can be exported
337 * @param bool $prefix
341 public static function &export($prefix = FALSE) {
342 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'phone', $prefix, []);
347 * Returns the list of indices
349 * @param bool $localize
353 public static function indices($localize = TRUE) {
355 'index_location_type' => [
356 'name' => 'index_location_type',
358 0 => 'location_type_id',
360 'localizable' => FALSE,
361 'sig' => 'civicrm_phone::0::location_type_id',
363 'index_is_primary' => [
364 'name' => 'index_is_primary',
368 'localizable' => FALSE,
369 'sig' => 'civicrm_phone::0::is_primary',
371 'index_is_billing' => [
372 'name' => 'index_is_billing',
376 'localizable' => FALSE,
377 'sig' => 'civicrm_phone::0::is_billing',
379 'UI_mobile_provider_id' => [
380 'name' => 'UI_mobile_provider_id',
382 0 => 'mobile_provider_id',
384 'localizable' => FALSE,
385 'sig' => 'civicrm_phone::0::mobile_provider_id',
387 'index_phone_numeric' => [
388 'name' => 'index_phone_numeric',
390 0 => 'phone_numeric',
392 'localizable' => FALSE,
393 'sig' => 'civicrm_phone::0::phone_numeric',
396 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;