5 * @copyright CiviCRM LLC (c) 2004-2020
7 * Generated from xml/schema/CRM/Core/Phone.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:a6e9de26d34f355e2365c6d4336f734f)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
46 * Which Location does this phone belong to.
50 public $location_type_id;
53 * Is this the primary phone for this contact and location.
60 * Is this the billing?
67 * Which Mobile Provider does this phone belong to.
71 public $mobile_provider_id;
74 * Complete phone number.
81 * Optional extension for a phone number.
88 * Phone number stripped of all whitespace, letters, and punctuation.
92 public $phone_numeric;
95 * Which type of phone does this number belongs.
99 public $phone_type_id;
104 public function __construct() {
105 $this->__table
= 'civicrm_phone';
106 parent
::__construct();
110 * Returns foreign keys and entity references.
113 * [CRM_Core_Reference_Interface]
115 public static function getReferenceColumns() {
116 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
117 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
118 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
119 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
121 return Civi
::$statics[__CLASS__
]['links'];
125 * Returns all the column names of this table
129 public static function &fields() {
130 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
131 Civi
::$statics[__CLASS__
]['fields'] = [
134 'type' => CRM_Utils_Type
::T_INT
,
135 'title' => ts('Phone ID'),
136 'description' => ts('Unique Phone ID'),
138 'where' => 'civicrm_phone.id',
139 'table_name' => 'civicrm_phone',
141 'bao' => 'CRM_Core_BAO_Phone',
145 'name' => 'contact_id',
146 'type' => CRM_Utils_Type
::T_INT
,
147 'title' => ts('Phone Contact'),
148 'description' => ts('FK to Contact ID'),
149 'where' => 'civicrm_phone.contact_id',
150 'table_name' => 'civicrm_phone',
152 'bao' => 'CRM_Core_BAO_Phone',
154 'FKClassName' => 'CRM_Contact_DAO_Contact',
156 'location_type_id' => [
157 'name' => 'location_type_id',
158 'type' => CRM_Utils_Type
::T_INT
,
159 'title' => ts('Phone Location Type'),
160 'description' => ts('Which Location does this phone belong to.'),
161 'where' => 'civicrm_phone.location_type_id',
162 'table_name' => 'civicrm_phone',
164 'bao' => 'CRM_Core_BAO_Phone',
169 'pseudoconstant' => [
170 'table' => 'civicrm_location_type',
172 'labelColumn' => 'display_name',
176 'name' => 'is_primary',
177 'type' => CRM_Utils_Type
::T_BOOLEAN
,
178 'title' => ts('Is Phone Primary?'),
179 'description' => ts('Is this the primary phone for this contact and location.'),
180 'where' => 'civicrm_phone.is_primary',
182 'table_name' => 'civicrm_phone',
184 'bao' => 'CRM_Core_BAO_Phone',
188 'name' => 'is_billing',
189 'type' => CRM_Utils_Type
::T_BOOLEAN
,
190 'title' => ts('Is Billing Phone'),
191 'description' => ts('Is this the billing?'),
192 'where' => 'civicrm_phone.is_billing',
194 'table_name' => 'civicrm_phone',
196 'bao' => 'CRM_Core_BAO_Phone',
199 'mobile_provider_id' => [
200 'name' => 'mobile_provider_id',
201 'type' => CRM_Utils_Type
::T_INT
,
202 'title' => ts('Mobile Provider'),
203 'description' => ts('Which Mobile Provider does this phone belong to.'),
204 'where' => 'civicrm_phone.mobile_provider_id',
205 'table_name' => 'civicrm_phone',
207 'bao' => 'CRM_Core_BAO_Phone',
212 'type' => CRM_Utils_Type
::T_STRING
,
213 'title' => ts('Phone'),
214 'description' => ts('Complete phone number.'),
216 'size' => CRM_Utils_Type
::MEDIUM
,
218 'where' => 'civicrm_phone.phone',
219 'headerPattern' => '/phone/i',
220 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
222 'table_name' => 'civicrm_phone',
224 'bao' => 'CRM_Core_BAO_Phone',
231 'name' => 'phone_ext',
232 'type' => CRM_Utils_Type
::T_STRING
,
233 'title' => ts('Phone Extension'),
234 'description' => ts('Optional extension for a phone number.'),
238 'where' => 'civicrm_phone.phone_ext',
239 'headerPattern' => '/extension/i',
240 'dataPattern' => '/^\d+$/',
242 'table_name' => 'civicrm_phone',
244 'bao' => 'CRM_Core_BAO_Phone',
251 'name' => 'phone_numeric',
252 'type' => CRM_Utils_Type
::T_STRING
,
253 'title' => ts('Phone Numeric'),
254 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
256 'size' => CRM_Utils_Type
::MEDIUM
,
257 'where' => 'civicrm_phone.phone_numeric',
258 'table_name' => 'civicrm_phone',
260 'bao' => 'CRM_Core_BAO_Phone',
264 'name' => 'phone_type_id',
265 'type' => CRM_Utils_Type
::T_INT
,
266 'title' => ts('Phone Type'),
267 'description' => ts('Which type of phone does this number belongs.'),
268 'where' => 'civicrm_phone.phone_type_id',
270 'table_name' => 'civicrm_phone',
272 'bao' => 'CRM_Core_BAO_Phone',
277 'pseudoconstant' => [
278 'optionGroupName' => 'phone_type',
279 'optionEditPath' => 'civicrm/admin/options/phone_type',
283 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
285 return Civi
::$statics[__CLASS__
]['fields'];
289 * Return a mapping from field-name to the corresponding key (as used in fields()).
292 * Array(string $name => string $uniqueName).
294 public static function &fieldKeys() {
295 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
296 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
298 return Civi
::$statics[__CLASS__
]['fieldKeys'];
302 * Returns the names of this table
306 public static function getTableName() {
307 return self
::$_tableName;
311 * Returns if this table needs to be logged
315 public function getLog() {
320 * Returns the list of fields that can be imported
322 * @param bool $prefix
326 public static function &import($prefix = FALSE) {
327 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'phone', $prefix, []);
332 * Returns the list of fields that can be exported
334 * @param bool $prefix
338 public static function &export($prefix = FALSE) {
339 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'phone', $prefix, []);
344 * Returns the list of indices
346 * @param bool $localize
350 public static function indices($localize = TRUE) {
352 'index_location_type' => [
353 'name' => 'index_location_type',
355 0 => 'location_type_id',
357 'localizable' => FALSE,
358 'sig' => 'civicrm_phone::0::location_type_id',
360 'index_is_primary' => [
361 'name' => 'index_is_primary',
365 'localizable' => FALSE,
366 'sig' => 'civicrm_phone::0::is_primary',
368 'index_is_billing' => [
369 'name' => 'index_is_billing',
373 'localizable' => FALSE,
374 'sig' => 'civicrm_phone::0::is_billing',
376 'UI_mobile_provider_id' => [
377 'name' => 'UI_mobile_provider_id',
379 0 => 'mobile_provider_id',
381 'localizable' => FALSE,
382 'sig' => 'civicrm_phone::0::mobile_provider_id',
384 'index_phone_numeric' => [
385 'name' => 'index_phone_numeric',
387 0 => 'phone_numeric',
389 'localizable' => FALSE,
390 'sig' => 'civicrm_phone::0::phone_numeric',
393 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;