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:3c1f1743128af72b009c6cf4effc1da2)
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 * Icon associated with this entity.
29 public static $_icon = 'fa-phone';
32 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 public static $_log = TRUE;
53 * Which Location does this phone belong to.
57 public $location_type_id;
60 * Is this the primary phone for this contact and location.
67 * Is this the billing?
74 * Which Mobile Provider does this phone belong to.
78 public $mobile_provider_id;
81 * Complete phone number.
88 * Optional extension for a phone number.
95 * Phone number stripped of all whitespace, letters, and punctuation.
99 public $phone_numeric;
102 * Which type of phone does this number belongs.
106 public $phone_type_id;
111 public function __construct() {
112 $this->__table
= 'civicrm_phone';
113 parent
::__construct();
117 * Returns localized title of this entity.
119 public static function getEntityTitle() {
124 * Returns foreign keys and entity references.
127 * [CRM_Core_Reference_Interface]
129 public static function getReferenceColumns() {
130 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
131 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
132 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
133 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
135 return Civi
::$statics[__CLASS__
]['links'];
139 * Returns all the column names of this table
143 public static function &fields() {
144 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
145 Civi
::$statics[__CLASS__
]['fields'] = [
148 'type' => CRM_Utils_Type
::T_INT
,
149 'title' => ts('Phone ID'),
150 'description' => ts('Unique Phone ID'),
152 'where' => 'civicrm_phone.id',
153 'table_name' => 'civicrm_phone',
155 'bao' => 'CRM_Core_BAO_Phone',
160 'name' => 'contact_id',
161 'type' => CRM_Utils_Type
::T_INT
,
162 'title' => ts('Phone Contact'),
163 'description' => ts('FK to Contact ID'),
164 'where' => 'civicrm_phone.contact_id',
165 'table_name' => 'civicrm_phone',
167 'bao' => 'CRM_Core_BAO_Phone',
169 'FKClassName' => 'CRM_Contact_DAO_Contact',
172 'location_type_id' => [
173 'name' => 'location_type_id',
174 'type' => CRM_Utils_Type
::T_INT
,
175 'title' => ts('Phone Location Type'),
176 'description' => ts('Which Location does this phone belong to.'),
177 'where' => 'civicrm_phone.location_type_id',
178 'table_name' => 'civicrm_phone',
180 'bao' => 'CRM_Core_BAO_Phone',
185 'pseudoconstant' => [
186 'table' => 'civicrm_location_type',
188 'labelColumn' => 'display_name',
193 'name' => 'is_primary',
194 'type' => CRM_Utils_Type
::T_BOOLEAN
,
195 'title' => ts('Primary phone'),
196 'description' => ts('Is this the primary phone for this contact and location.'),
197 'where' => 'civicrm_phone.is_primary',
199 'table_name' => 'civicrm_phone',
201 'bao' => 'CRM_Core_BAO_Phone',
209 'name' => 'is_billing',
210 'type' => CRM_Utils_Type
::T_BOOLEAN
,
211 'title' => ts('Is Billing Phone'),
212 'description' => ts('Is this the billing?'),
213 'where' => 'civicrm_phone.is_billing',
215 'table_name' => 'civicrm_phone',
217 'bao' => 'CRM_Core_BAO_Phone',
221 'mobile_provider_id' => [
222 'name' => 'mobile_provider_id',
223 'type' => CRM_Utils_Type
::T_INT
,
224 'title' => ts('Mobile Provider'),
225 'description' => ts('Which Mobile Provider does this phone belong to.'),
226 'where' => 'civicrm_phone.mobile_provider_id',
227 'table_name' => 'civicrm_phone',
229 'bao' => 'CRM_Core_BAO_Phone',
235 'type' => CRM_Utils_Type
::T_STRING
,
236 'title' => ts('Phone'),
237 'description' => ts('Complete phone number.'),
239 'size' => CRM_Utils_Type
::MEDIUM
,
241 'where' => 'civicrm_phone.phone',
242 'headerPattern' => '/phone/i',
243 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
245 'table_name' => 'civicrm_phone',
247 'bao' => 'CRM_Core_BAO_Phone',
255 'name' => 'phone_ext',
256 'type' => CRM_Utils_Type
::T_STRING
,
257 'title' => ts('Phone Extension'),
258 'description' => ts('Optional extension for a phone number.'),
262 'where' => 'civicrm_phone.phone_ext',
263 'headerPattern' => '/extension/i',
264 'dataPattern' => '/^\d+$/',
266 'table_name' => 'civicrm_phone',
268 'bao' => 'CRM_Core_BAO_Phone',
276 'name' => 'phone_numeric',
277 'type' => CRM_Utils_Type
::T_STRING
,
278 'title' => ts('Phone Numeric'),
279 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
281 'size' => CRM_Utils_Type
::MEDIUM
,
282 'where' => 'civicrm_phone.phone_numeric',
283 'table_name' => 'civicrm_phone',
285 'bao' => 'CRM_Core_BAO_Phone',
290 'name' => 'phone_type_id',
291 'type' => CRM_Utils_Type
::T_INT
,
292 'title' => ts('Phone Type'),
293 'description' => ts('Which type of phone does this number belongs.'),
294 'where' => 'civicrm_phone.phone_type_id',
296 'table_name' => 'civicrm_phone',
298 'bao' => 'CRM_Core_BAO_Phone',
303 'pseudoconstant' => [
304 'optionGroupName' => 'phone_type',
305 'optionEditPath' => 'civicrm/admin/options/phone_type',
310 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
312 return Civi
::$statics[__CLASS__
]['fields'];
316 * Return a mapping from field-name to the corresponding key (as used in fields()).
319 * Array(string $name => string $uniqueName).
321 public static function &fieldKeys() {
322 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
323 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
325 return Civi
::$statics[__CLASS__
]['fieldKeys'];
329 * Returns the names of this table
333 public static function getTableName() {
334 return self
::$_tableName;
338 * Returns if this table needs to be logged
342 public function getLog() {
347 * Returns the list of fields that can be imported
349 * @param bool $prefix
353 public static function &import($prefix = FALSE) {
354 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'phone', $prefix, []);
359 * Returns the list of fields that can be exported
361 * @param bool $prefix
365 public static function &export($prefix = FALSE) {
366 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'phone', $prefix, []);
371 * Returns the list of indices
373 * @param bool $localize
377 public static function indices($localize = TRUE) {
379 'index_location_type' => [
380 'name' => 'index_location_type',
382 0 => 'location_type_id',
384 'localizable' => FALSE,
385 'sig' => 'civicrm_phone::0::location_type_id',
387 'index_is_primary' => [
388 'name' => 'index_is_primary',
392 'localizable' => FALSE,
393 'sig' => 'civicrm_phone::0::is_primary',
395 'index_is_billing' => [
396 'name' => 'index_is_billing',
400 'localizable' => FALSE,
401 'sig' => 'civicrm_phone::0::is_billing',
403 'UI_mobile_provider_id' => [
404 'name' => 'UI_mobile_provider_id',
406 0 => 'mobile_provider_id',
408 'localizable' => FALSE,
409 'sig' => 'civicrm_phone::0::mobile_provider_id',
411 'index_phone_numeric' => [
412 'name' => 'index_phone_numeric',
414 0 => 'phone_numeric',
416 'localizable' => FALSE,
417 'sig' => 'civicrm_phone::0::phone_numeric',
420 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;