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:69c5bce12cbed1144a0c38eec1052206)
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;
62 * Which Location does this phone belong to.
66 public $location_type_id;
69 * Is this the primary phone for this contact and location.
76 * Is this the billing?
83 * Which Mobile Provider does this phone belong to.
87 public $mobile_provider_id;
90 * Complete phone number.
97 * Optional extension for a phone number.
104 * Phone number stripped of all whitespace, letters, and punctuation.
108 public $phone_numeric;
111 * Which type of phone does this number belongs.
115 public $phone_type_id;
120 public function __construct() {
121 $this->__table
= 'civicrm_phone';
122 parent
::__construct();
126 * Returns localized title of this entity.
128 * @param bool $plural
129 * Whether to return the plural version of the title.
131 public static function getEntityTitle($plural = FALSE) {
132 return $plural ?
ts('Phones') : ts('Phone');
136 * Returns foreign keys and entity references.
139 * [CRM_Core_Reference_Interface]
141 public static function getReferenceColumns() {
142 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
143 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
144 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
145 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
147 return Civi
::$statics[__CLASS__
]['links'];
151 * Returns all the column names of this table
155 public static function &fields() {
156 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
157 Civi
::$statics[__CLASS__
]['fields'] = [
160 'type' => CRM_Utils_Type
::T_INT
,
161 'title' => ts('Phone ID'),
162 'description' => ts('Unique Phone ID'),
164 'where' => 'civicrm_phone.id',
165 'table_name' => 'civicrm_phone',
167 'bao' => 'CRM_Core_BAO_Phone',
175 'name' => 'contact_id',
176 'type' => CRM_Utils_Type
::T_INT
,
177 'title' => ts('Contact ID'),
178 'description' => ts('FK to Contact ID'),
179 'where' => 'civicrm_phone.contact_id',
180 'table_name' => 'civicrm_phone',
182 'bao' => 'CRM_Core_BAO_Phone',
184 'FKClassName' => 'CRM_Contact_DAO_Contact',
186 'label' => ts("Contact"),
190 'location_type_id' => [
191 'name' => 'location_type_id',
192 'type' => CRM_Utils_Type
::T_INT
,
193 'title' => ts('Location Type ID'),
194 'description' => ts('Which Location does this phone belong to.'),
195 'where' => 'civicrm_phone.location_type_id',
196 'table_name' => 'civicrm_phone',
198 'bao' => 'CRM_Core_BAO_Phone',
202 'label' => ts("Location Type"),
204 'pseudoconstant' => [
205 'table' => 'civicrm_location_type',
207 'labelColumn' => 'display_name',
212 'name' => 'is_primary',
213 'type' => CRM_Utils_Type
::T_BOOLEAN
,
214 'title' => ts('Primary phone'),
215 'description' => ts('Is this the primary phone for this contact and location.'),
216 'where' => 'civicrm_phone.is_primary',
218 'table_name' => 'civicrm_phone',
220 'bao' => 'CRM_Core_BAO_Phone',
228 'name' => 'is_billing',
229 'type' => CRM_Utils_Type
::T_BOOLEAN
,
230 'title' => ts('Is Billing Phone'),
231 'description' => ts('Is this the billing?'),
232 'where' => 'civicrm_phone.is_billing',
234 'table_name' => 'civicrm_phone',
236 'bao' => 'CRM_Core_BAO_Phone',
240 'mobile_provider_id' => [
241 'name' => 'mobile_provider_id',
242 'type' => CRM_Utils_Type
::T_INT
,
243 'title' => ts('Mobile Provider'),
244 'description' => ts('Which Mobile Provider does this phone belong to.'),
245 'where' => 'civicrm_phone.mobile_provider_id',
246 'table_name' => 'civicrm_phone',
248 'bao' => 'CRM_Core_BAO_Phone',
254 'type' => CRM_Utils_Type
::T_STRING
,
255 'title' => ts('Phone'),
256 'description' => ts('Complete phone number.'),
258 'size' => CRM_Utils_Type
::MEDIUM
,
260 'where' => 'civicrm_phone.phone',
261 'headerPattern' => '/phone/i',
262 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
264 'table_name' => 'civicrm_phone',
266 'bao' => 'CRM_Core_BAO_Phone',
270 'label' => ts("Phone"),
275 'name' => 'phone_ext',
276 'type' => CRM_Utils_Type
::T_STRING
,
277 'title' => ts('Phone Extension'),
278 'description' => ts('Optional extension for a phone number.'),
282 'where' => 'civicrm_phone.phone_ext',
283 'headerPattern' => '/extension/i',
284 'dataPattern' => '/^\d+$/',
286 'table_name' => 'civicrm_phone',
288 'bao' => 'CRM_Core_BAO_Phone',
296 'name' => 'phone_numeric',
297 'type' => CRM_Utils_Type
::T_STRING
,
298 'title' => ts('Phone Numeric'),
299 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
301 'size' => CRM_Utils_Type
::MEDIUM
,
302 'where' => 'civicrm_phone.phone_numeric',
303 'table_name' => 'civicrm_phone',
305 'bao' => 'CRM_Core_BAO_Phone',
308 'label' => ts("Numeric"),
313 'name' => 'phone_type_id',
314 'type' => CRM_Utils_Type
::T_INT
,
315 'title' => ts('Phone Type ID'),
316 'description' => ts('Which type of phone does this number belongs.'),
317 'where' => 'civicrm_phone.phone_type_id',
319 'table_name' => 'civicrm_phone',
321 'bao' => 'CRM_Core_BAO_Phone',
325 'label' => ts("Phone Type"),
327 'pseudoconstant' => [
328 'optionGroupName' => 'phone_type',
329 'optionEditPath' => 'civicrm/admin/options/phone_type',
334 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
336 return Civi
::$statics[__CLASS__
]['fields'];
340 * Return a mapping from field-name to the corresponding key (as used in fields()).
343 * Array(string $name => string $uniqueName).
345 public static function &fieldKeys() {
346 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
347 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
349 return Civi
::$statics[__CLASS__
]['fieldKeys'];
353 * Returns the names of this table
357 public static function getTableName() {
358 return self
::$_tableName;
362 * Returns if this table needs to be logged
366 public function getLog() {
371 * Returns the list of fields that can be imported
373 * @param bool $prefix
377 public static function &import($prefix = FALSE) {
378 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'phone', $prefix, []);
383 * Returns the list of fields that can be exported
385 * @param bool $prefix
389 public static function &export($prefix = FALSE) {
390 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'phone', $prefix, []);
395 * Returns the list of indices
397 * @param bool $localize
401 public static function indices($localize = TRUE) {
403 'index_location_type' => [
404 'name' => 'index_location_type',
406 0 => 'location_type_id',
408 'localizable' => FALSE,
409 'sig' => 'civicrm_phone::0::location_type_id',
411 'index_is_primary' => [
412 'name' => 'index_is_primary',
416 'localizable' => FALSE,
417 'sig' => 'civicrm_phone::0::is_primary',
419 'index_is_billing' => [
420 'name' => 'index_is_billing',
424 'localizable' => FALSE,
425 'sig' => 'civicrm_phone::0::is_billing',
427 'UI_mobile_provider_id' => [
428 'name' => 'UI_mobile_provider_id',
430 0 => 'mobile_provider_id',
432 'localizable' => FALSE,
433 'sig' => 'civicrm_phone::0::mobile_provider_id',
435 'index_phone_numeric' => [
436 'name' => 'index_phone_numeric',
438 0 => 'phone_numeric',
440 'localizable' => FALSE,
441 'sig' => 'civicrm_phone::0::phone_numeric',
444 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;