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:76f82c31308292a82535fb6bcf6acc4d)
13 * Database access object for the Phone entity.
15 class CRM_Core_DAO_Phone
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_phone';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-phone';
34 * Field to show when displaying a record.
38 public static $_labelField = 'phone';
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
45 public static $_log = TRUE;
50 * @var int|string|null
51 * (SQL type: int unsigned)
52 * Note that values will be retrieved from the database as a string.
59 * @var int|string|null
60 * (SQL type: int unsigned)
61 * Note that values will be retrieved from the database as a string.
66 * Which Location does this phone belong to.
68 * @var int|string|null
69 * (SQL type: int unsigned)
70 * Note that values will be retrieved from the database as a string.
72 public $location_type_id;
75 * Is this the primary phone for this contact and location.
77 * @var bool|string|null
79 * Note that values will be retrieved from the database as a string.
84 * Is this the billing?
86 * @var bool|string|null
88 * Note that values will be retrieved from the database as a string.
93 * Which Mobile Provider does this phone belong to.
95 * @var int|string|null
96 * (SQL type: int unsigned)
97 * Note that values will be retrieved from the database as a string.
99 public $mobile_provider_id;
102 * Complete phone number.
105 * (SQL type: varchar(32))
106 * Note that values will be retrieved from the database as a string.
111 * Optional extension for a phone number.
114 * (SQL type: varchar(16))
115 * Note that values will be retrieved from the database as a string.
120 * Phone number stripped of all whitespace, letters, and punctuation.
123 * (SQL type: varchar(32))
124 * Note that values will be retrieved from the database as a string.
126 public $phone_numeric;
129 * Which type of phone does this number belongs.
131 * @var int|string|null
132 * (SQL type: int unsigned)
133 * Note that values will be retrieved from the database as a string.
135 public $phone_type_id;
140 public function __construct() {
141 $this->__table
= 'civicrm_phone';
142 parent
::__construct();
146 * Returns localized title of this entity.
148 * @param bool $plural
149 * Whether to return the plural version of the title.
151 public static function getEntityTitle($plural = FALSE) {
152 return $plural ?
ts('Phones') : ts('Phone');
156 * Returns foreign keys and entity references.
159 * [CRM_Core_Reference_Interface]
161 public static function getReferenceColumns() {
162 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
163 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
164 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
165 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
167 return Civi
::$statics[__CLASS__
]['links'];
171 * Returns all the column names of this table
175 public static function &fields() {
176 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
177 Civi
::$statics[__CLASS__
]['fields'] = [
180 'type' => CRM_Utils_Type
::T_INT
,
181 'title' => ts('Phone ID'),
182 'description' => ts('Unique Phone ID'),
184 'where' => 'civicrm_phone.id',
185 'table_name' => 'civicrm_phone',
187 'bao' => 'CRM_Core_BAO_Phone',
196 'name' => 'contact_id',
197 'type' => CRM_Utils_Type
::T_INT
,
198 'title' => ts('Contact ID'),
199 'description' => ts('FK to Contact ID'),
200 'where' => 'civicrm_phone.contact_id',
201 'table_name' => 'civicrm_phone',
203 'bao' => 'CRM_Core_BAO_Phone',
205 'FKClassName' => 'CRM_Contact_DAO_Contact',
207 'label' => ts("Contact"),
211 'location_type_id' => [
212 'name' => 'location_type_id',
213 'type' => CRM_Utils_Type
::T_INT
,
214 'title' => ts('Location Type ID'),
215 'description' => ts('Which Location does this phone belong to.'),
216 'where' => 'civicrm_phone.location_type_id',
217 'table_name' => 'civicrm_phone',
219 'bao' => 'CRM_Core_BAO_Phone',
223 'label' => ts("Location Type"),
225 'pseudoconstant' => [
226 'table' => 'civicrm_location_type',
228 'labelColumn' => 'display_name',
233 'name' => 'is_primary',
234 'type' => CRM_Utils_Type
::T_BOOLEAN
,
235 'title' => ts('Primary phone'),
236 'description' => ts('Is this the primary phone for this contact and location.'),
237 'where' => 'civicrm_phone.is_primary',
239 'table_name' => 'civicrm_phone',
241 'bao' => 'CRM_Core_BAO_Phone',
249 'name' => 'is_billing',
250 'type' => CRM_Utils_Type
::T_BOOLEAN
,
251 'title' => ts('Is Billing Phone'),
252 'description' => ts('Is this the billing?'),
253 'where' => 'civicrm_phone.is_billing',
255 'table_name' => 'civicrm_phone',
257 'bao' => 'CRM_Core_BAO_Phone',
261 'mobile_provider_id' => [
262 'name' => 'mobile_provider_id',
263 'type' => CRM_Utils_Type
::T_INT
,
264 'title' => ts('Mobile Provider'),
265 'description' => ts('Which Mobile Provider does this phone belong to.'),
266 'where' => 'civicrm_phone.mobile_provider_id',
267 'table_name' => 'civicrm_phone',
269 'bao' => 'CRM_Core_BAO_Phone',
275 'type' => CRM_Utils_Type
::T_STRING
,
276 'title' => ts('Phone'),
277 'description' => ts('Complete phone number.'),
279 'size' => CRM_Utils_Type
::MEDIUM
,
281 'where' => 'civicrm_phone.phone',
282 'headerPattern' => '/phone/i',
283 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
285 'table_name' => 'civicrm_phone',
287 'bao' => 'CRM_Core_BAO_Phone',
291 'label' => ts("Phone"),
296 'name' => 'phone_ext',
297 'type' => CRM_Utils_Type
::T_STRING
,
298 'title' => ts('Phone Extension'),
299 'description' => ts('Optional extension for a phone number.'),
303 'where' => 'civicrm_phone.phone_ext',
304 'headerPattern' => '/extension/i',
305 'dataPattern' => '/^\d+$/',
307 'table_name' => 'civicrm_phone',
309 'bao' => 'CRM_Core_BAO_Phone',
317 'name' => 'phone_numeric',
318 'type' => CRM_Utils_Type
::T_STRING
,
319 'title' => ts('Phone Numeric'),
320 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
322 'size' => CRM_Utils_Type
::MEDIUM
,
323 'where' => 'civicrm_phone.phone_numeric',
324 'table_name' => 'civicrm_phone',
326 'bao' => 'CRM_Core_BAO_Phone',
329 'label' => ts("Numeric"),
334 'name' => 'phone_type_id',
335 'type' => CRM_Utils_Type
::T_INT
,
336 'title' => ts('Phone Type ID'),
337 'description' => ts('Which type of phone does this number belongs.'),
338 'where' => 'civicrm_phone.phone_type_id',
340 'table_name' => 'civicrm_phone',
342 'bao' => 'CRM_Core_BAO_Phone',
346 'label' => ts("Phone Type"),
348 'pseudoconstant' => [
349 'optionGroupName' => 'phone_type',
350 'optionEditPath' => 'civicrm/admin/options/phone_type',
355 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
357 return Civi
::$statics[__CLASS__
]['fields'];
361 * Return a mapping from field-name to the corresponding key (as used in fields()).
364 * Array(string $name => string $uniqueName).
366 public static function &fieldKeys() {
367 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
368 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
370 return Civi
::$statics[__CLASS__
]['fieldKeys'];
374 * Returns the names of this table
378 public static function getTableName() {
379 return self
::$_tableName;
383 * Returns if this table needs to be logged
387 public function getLog() {
392 * Returns the list of fields that can be imported
394 * @param bool $prefix
398 public static function &import($prefix = FALSE) {
399 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'phone', $prefix, []);
404 * Returns the list of fields that can be exported
406 * @param bool $prefix
410 public static function &export($prefix = FALSE) {
411 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'phone', $prefix, []);
416 * Returns the list of indices
418 * @param bool $localize
422 public static function indices($localize = TRUE) {
424 'index_location_type' => [
425 'name' => 'index_location_type',
427 0 => 'location_type_id',
429 'localizable' => FALSE,
430 'sig' => 'civicrm_phone::0::location_type_id',
432 'index_is_primary' => [
433 'name' => 'index_is_primary',
437 'localizable' => FALSE,
438 'sig' => 'civicrm_phone::0::is_primary',
440 'index_is_billing' => [
441 'name' => 'index_is_billing',
445 'localizable' => FALSE,
446 'sig' => 'civicrm_phone::0::is_billing',
448 'UI_mobile_provider_id' => [
449 'name' => 'UI_mobile_provider_id',
451 0 => 'mobile_provider_id',
453 'localizable' => FALSE,
454 'sig' => 'civicrm_phone::0::mobile_provider_id',
456 'index_phone_numeric' => [
457 'name' => 'index_phone_numeric',
459 0 => 'phone_numeric',
461 'localizable' => FALSE,
462 'sig' => 'civicrm_phone::0::phone_numeric',
465 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;