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:b10c818f0a807eacffe604063455467f)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
55 * Which Location does this phone belong to.
59 public $location_type_id;
62 * Is this the primary phone for this contact and location.
69 * Is this the billing?
76 * Which Mobile Provider does this phone belong to.
80 public $mobile_provider_id;
83 * Complete phone number.
90 * Optional extension for a phone number.
97 * Phone number stripped of all whitespace, letters, and punctuation.
101 public $phone_numeric;
104 * Which type of phone does this number belongs.
108 public $phone_type_id;
113 public function __construct() {
114 $this->__table
= 'civicrm_phone';
115 parent
::__construct();
119 * Returns localized title of this entity.
121 public static function getEntityTitle() {
126 * Returns foreign keys and entity references.
129 * [CRM_Core_Reference_Interface]
131 public static function getReferenceColumns() {
132 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
133 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
134 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
135 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
137 return Civi
::$statics[__CLASS__
]['links'];
141 * Returns all the column names of this table
145 public static function &fields() {
146 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
147 Civi
::$statics[__CLASS__
]['fields'] = [
150 'type' => CRM_Utils_Type
::T_INT
,
151 'title' => ts('Phone ID'),
152 'description' => ts('Unique Phone ID'),
154 'where' => 'civicrm_phone.id',
155 'table_name' => 'civicrm_phone',
157 'bao' => 'CRM_Core_BAO_Phone',
162 'name' => 'contact_id',
163 'type' => CRM_Utils_Type
::T_INT
,
164 'title' => ts('Phone Contact'),
165 'description' => ts('FK to Contact ID'),
166 'where' => 'civicrm_phone.contact_id',
167 'table_name' => 'civicrm_phone',
169 'bao' => 'CRM_Core_BAO_Phone',
171 'FKClassName' => 'CRM_Contact_DAO_Contact',
174 'location_type_id' => [
175 'name' => 'location_type_id',
176 'type' => CRM_Utils_Type
::T_INT
,
177 'title' => ts('Phone Location Type'),
178 'description' => ts('Which Location does this phone belong to.'),
179 'where' => 'civicrm_phone.location_type_id',
180 'table_name' => 'civicrm_phone',
182 'bao' => 'CRM_Core_BAO_Phone',
187 'pseudoconstant' => [
188 'table' => 'civicrm_location_type',
190 'labelColumn' => 'display_name',
195 'name' => 'is_primary',
196 'type' => CRM_Utils_Type
::T_BOOLEAN
,
197 'title' => ts('Primary phone'),
198 'description' => ts('Is this the primary phone for this contact and location.'),
199 'where' => 'civicrm_phone.is_primary',
201 'table_name' => 'civicrm_phone',
203 'bao' => 'CRM_Core_BAO_Phone',
211 'name' => 'is_billing',
212 'type' => CRM_Utils_Type
::T_BOOLEAN
,
213 'title' => ts('Is Billing Phone'),
214 'description' => ts('Is this the billing?'),
215 'where' => 'civicrm_phone.is_billing',
217 'table_name' => 'civicrm_phone',
219 'bao' => 'CRM_Core_BAO_Phone',
223 'mobile_provider_id' => [
224 'name' => 'mobile_provider_id',
225 'type' => CRM_Utils_Type
::T_INT
,
226 'title' => ts('Mobile Provider'),
227 'description' => ts('Which Mobile Provider does this phone belong to.'),
228 'where' => 'civicrm_phone.mobile_provider_id',
229 'table_name' => 'civicrm_phone',
231 'bao' => 'CRM_Core_BAO_Phone',
237 'type' => CRM_Utils_Type
::T_STRING
,
238 'title' => ts('Phone'),
239 'description' => ts('Complete phone number.'),
241 'size' => CRM_Utils_Type
::MEDIUM
,
243 'where' => 'civicrm_phone.phone',
244 'headerPattern' => '/phone/i',
245 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
247 'table_name' => 'civicrm_phone',
249 'bao' => 'CRM_Core_BAO_Phone',
257 'name' => 'phone_ext',
258 'type' => CRM_Utils_Type
::T_STRING
,
259 'title' => ts('Phone Extension'),
260 'description' => ts('Optional extension for a phone number.'),
264 'where' => 'civicrm_phone.phone_ext',
265 'headerPattern' => '/extension/i',
266 'dataPattern' => '/^\d+$/',
268 'table_name' => 'civicrm_phone',
270 'bao' => 'CRM_Core_BAO_Phone',
278 'name' => 'phone_numeric',
279 'type' => CRM_Utils_Type
::T_STRING
,
280 'title' => ts('Phone Numeric'),
281 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
283 'size' => CRM_Utils_Type
::MEDIUM
,
284 'where' => 'civicrm_phone.phone_numeric',
285 'table_name' => 'civicrm_phone',
287 'bao' => 'CRM_Core_BAO_Phone',
292 'name' => 'phone_type_id',
293 'type' => CRM_Utils_Type
::T_INT
,
294 'title' => ts('Phone Type ID'),
295 'description' => ts('Which type of phone does this number belongs.'),
296 'where' => 'civicrm_phone.phone_type_id',
298 'table_name' => 'civicrm_phone',
300 'bao' => 'CRM_Core_BAO_Phone',
305 'pseudoconstant' => [
306 'optionGroupName' => 'phone_type',
307 'optionEditPath' => 'civicrm/admin/options/phone_type',
312 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
314 return Civi
::$statics[__CLASS__
]['fields'];
318 * Return a mapping from field-name to the corresponding key (as used in fields()).
321 * Array(string $name => string $uniqueName).
323 public static function &fieldKeys() {
324 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
325 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
327 return Civi
::$statics[__CLASS__
]['fieldKeys'];
331 * Returns the names of this table
335 public static function getTableName() {
336 return self
::$_tableName;
340 * Returns if this table needs to be logged
344 public function getLog() {
349 * Returns the list of fields that can be imported
351 * @param bool $prefix
355 public static function &import($prefix = FALSE) {
356 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'phone', $prefix, []);
361 * Returns the list of fields that can be exported
363 * @param bool $prefix
367 public static function &export($prefix = FALSE) {
368 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'phone', $prefix, []);
373 * Returns the list of indices
375 * @param bool $localize
379 public static function indices($localize = TRUE) {
381 'index_location_type' => [
382 'name' => 'index_location_type',
384 0 => 'location_type_id',
386 'localizable' => FALSE,
387 'sig' => 'civicrm_phone::0::location_type_id',
389 'index_is_primary' => [
390 'name' => 'index_is_primary',
394 'localizable' => FALSE,
395 'sig' => 'civicrm_phone::0::is_primary',
397 'index_is_billing' => [
398 'name' => 'index_is_billing',
402 'localizable' => FALSE,
403 'sig' => 'civicrm_phone::0::is_billing',
405 'UI_mobile_provider_id' => [
406 'name' => 'UI_mobile_provider_id',
408 0 => 'mobile_provider_id',
410 'localizable' => FALSE,
411 'sig' => 'civicrm_phone::0::mobile_provider_id',
413 'index_phone_numeric' => [
414 'name' => 'index_phone_numeric',
416 0 => 'phone_numeric',
418 'localizable' => FALSE,
419 'sig' => 'civicrm_phone::0::phone_numeric',
422 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;