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:dcfc4989d248f3990a5ac2a422597061)
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',
159 'name' => 'contact_id',
160 'type' => CRM_Utils_Type
::T_INT
,
161 'title' => ts('Phone Contact'),
162 'description' => ts('FK to Contact ID'),
163 'where' => 'civicrm_phone.contact_id',
164 'table_name' => 'civicrm_phone',
166 'bao' => 'CRM_Core_BAO_Phone',
168 'FKClassName' => 'CRM_Contact_DAO_Contact',
170 'location_type_id' => [
171 'name' => 'location_type_id',
172 'type' => CRM_Utils_Type
::T_INT
,
173 'title' => ts('Phone Location Type'),
174 'description' => ts('Which Location does this phone belong to.'),
175 'where' => 'civicrm_phone.location_type_id',
176 'table_name' => 'civicrm_phone',
178 'bao' => 'CRM_Core_BAO_Phone',
183 'pseudoconstant' => [
184 'table' => 'civicrm_location_type',
186 'labelColumn' => 'display_name',
190 'name' => 'is_primary',
191 'type' => CRM_Utils_Type
::T_BOOLEAN
,
192 'title' => ts('Primary phone'),
193 'description' => ts('Is this the primary phone for this contact and location.'),
194 'where' => 'civicrm_phone.is_primary',
196 'table_name' => 'civicrm_phone',
198 'bao' => 'CRM_Core_BAO_Phone',
205 'name' => 'is_billing',
206 'type' => CRM_Utils_Type
::T_BOOLEAN
,
207 'title' => ts('Is Billing Phone'),
208 'description' => ts('Is this the billing?'),
209 'where' => 'civicrm_phone.is_billing',
211 'table_name' => 'civicrm_phone',
213 'bao' => 'CRM_Core_BAO_Phone',
216 'mobile_provider_id' => [
217 'name' => 'mobile_provider_id',
218 'type' => CRM_Utils_Type
::T_INT
,
219 'title' => ts('Mobile Provider'),
220 'description' => ts('Which Mobile Provider does this phone belong to.'),
221 'where' => 'civicrm_phone.mobile_provider_id',
222 'table_name' => 'civicrm_phone',
224 'bao' => 'CRM_Core_BAO_Phone',
229 'type' => CRM_Utils_Type
::T_STRING
,
230 'title' => ts('Phone'),
231 'description' => ts('Complete phone number.'),
233 'size' => CRM_Utils_Type
::MEDIUM
,
235 'where' => 'civicrm_phone.phone',
236 'headerPattern' => '/phone/i',
237 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
239 'table_name' => 'civicrm_phone',
241 'bao' => 'CRM_Core_BAO_Phone',
248 'name' => 'phone_ext',
249 'type' => CRM_Utils_Type
::T_STRING
,
250 'title' => ts('Phone Extension'),
251 'description' => ts('Optional extension for a phone number.'),
255 'where' => 'civicrm_phone.phone_ext',
256 'headerPattern' => '/extension/i',
257 'dataPattern' => '/^\d+$/',
259 'table_name' => 'civicrm_phone',
261 'bao' => 'CRM_Core_BAO_Phone',
268 'name' => 'phone_numeric',
269 'type' => CRM_Utils_Type
::T_STRING
,
270 'title' => ts('Phone Numeric'),
271 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
273 'size' => CRM_Utils_Type
::MEDIUM
,
274 'where' => 'civicrm_phone.phone_numeric',
275 'table_name' => 'civicrm_phone',
277 'bao' => 'CRM_Core_BAO_Phone',
281 'name' => 'phone_type_id',
282 'type' => CRM_Utils_Type
::T_INT
,
283 'title' => ts('Phone Type'),
284 'description' => ts('Which type of phone does this number belongs.'),
285 'where' => 'civicrm_phone.phone_type_id',
287 'table_name' => 'civicrm_phone',
289 'bao' => 'CRM_Core_BAO_Phone',
294 'pseudoconstant' => [
295 'optionGroupName' => 'phone_type',
296 'optionEditPath' => 'civicrm/admin/options/phone_type',
300 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
302 return Civi
::$statics[__CLASS__
]['fields'];
306 * Return a mapping from field-name to the corresponding key (as used in fields()).
309 * Array(string $name => string $uniqueName).
311 public static function &fieldKeys() {
312 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
313 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
315 return Civi
::$statics[__CLASS__
]['fieldKeys'];
319 * Returns the names of this table
323 public static function getTableName() {
324 return self
::$_tableName;
328 * Returns if this table needs to be logged
332 public function getLog() {
337 * Returns the list of fields that can be imported
339 * @param bool $prefix
343 public static function &import($prefix = FALSE) {
344 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'phone', $prefix, []);
349 * Returns the list of fields that can be exported
351 * @param bool $prefix
355 public static function &export($prefix = FALSE) {
356 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'phone', $prefix, []);
361 * Returns the list of indices
363 * @param bool $localize
367 public static function indices($localize = TRUE) {
369 'index_location_type' => [
370 'name' => 'index_location_type',
372 0 => 'location_type_id',
374 'localizable' => FALSE,
375 'sig' => 'civicrm_phone::0::location_type_id',
377 'index_is_primary' => [
378 'name' => 'index_is_primary',
382 'localizable' => FALSE,
383 'sig' => 'civicrm_phone::0::is_primary',
385 'index_is_billing' => [
386 'name' => 'index_is_billing',
390 'localizable' => FALSE,
391 'sig' => 'civicrm_phone::0::is_billing',
393 'UI_mobile_provider_id' => [
394 'name' => 'UI_mobile_provider_id',
396 0 => 'mobile_provider_id',
398 'localizable' => FALSE,
399 'sig' => 'civicrm_phone::0::mobile_provider_id',
401 'index_phone_numeric' => [
402 'name' => 'index_phone_numeric',
404 0 => 'phone_numeric',
406 'localizable' => FALSE,
407 'sig' => 'civicrm_phone::0::phone_numeric',
410 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;