5 * @copyright CiviCRM LLC (c) 2004-2018
7 * Generated from xml/schema/CRM/Core/Phone.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:a3b4aba6b896154133688f4318ea866b)
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 static $_tableName = 'civicrm_phone';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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 'table_name' => 'civicrm_phone',
140 'bao' => 'CRM_Core_BAO_Phone',
144 'name' => 'contact_id',
145 'type' => CRM_Utils_Type
::T_INT
,
146 'title' => ts('Phone Contact'),
147 'description' => ts('FK to Contact ID'),
148 'table_name' => 'civicrm_phone',
150 'bao' => 'CRM_Core_BAO_Phone',
152 'FKClassName' => 'CRM_Contact_DAO_Contact',
154 'location_type_id' => [
155 'name' => 'location_type_id',
156 'type' => CRM_Utils_Type
::T_INT
,
157 'title' => ts('Phone Location Type'),
158 'description' => ts('Which Location does this phone belong to.'),
159 'table_name' => 'civicrm_phone',
161 'bao' => 'CRM_Core_BAO_Phone',
166 'pseudoconstant' => [
167 'table' => 'civicrm_location_type',
169 'labelColumn' => 'display_name',
173 'name' => 'is_primary',
174 'type' => CRM_Utils_Type
::T_BOOLEAN
,
175 'title' => ts('Is Phone Primary?'),
176 'description' => ts('Is this the primary phone for this contact and location.'),
178 'table_name' => 'civicrm_phone',
180 'bao' => 'CRM_Core_BAO_Phone',
184 'name' => 'is_billing',
185 'type' => CRM_Utils_Type
::T_BOOLEAN
,
186 'title' => ts('Is Billing Phone'),
187 'description' => ts('Is this the billing?'),
189 'table_name' => 'civicrm_phone',
191 'bao' => 'CRM_Core_BAO_Phone',
194 'mobile_provider_id' => [
195 'name' => 'mobile_provider_id',
196 'type' => CRM_Utils_Type
::T_INT
,
197 'title' => ts('Mobile Provider'),
198 'description' => ts('Which Mobile Provider does this phone belong to.'),
199 'table_name' => 'civicrm_phone',
201 'bao' => 'CRM_Core_BAO_Phone',
206 'type' => CRM_Utils_Type
::T_STRING
,
207 'title' => ts('Phone'),
208 'description' => ts('Complete phone number.'),
210 'size' => CRM_Utils_Type
::MEDIUM
,
212 'where' => 'civicrm_phone.phone',
213 'headerPattern' => '/phone/i',
214 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
216 'table_name' => 'civicrm_phone',
218 'bao' => 'CRM_Core_BAO_Phone',
225 'name' => 'phone_ext',
226 'type' => CRM_Utils_Type
::T_STRING
,
227 'title' => ts('Phone Extension'),
228 'description' => ts('Optional extension for a phone number.'),
232 'where' => 'civicrm_phone.phone_ext',
233 'headerPattern' => '/extension/i',
234 'dataPattern' => '/^\d+$/',
236 'table_name' => 'civicrm_phone',
238 'bao' => 'CRM_Core_BAO_Phone',
245 'name' => 'phone_numeric',
246 'type' => CRM_Utils_Type
::T_STRING
,
247 'title' => ts('Phone Numeric'),
248 'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
250 'size' => CRM_Utils_Type
::MEDIUM
,
251 'table_name' => 'civicrm_phone',
253 'bao' => 'CRM_Core_BAO_Phone',
257 'name' => 'phone_type_id',
258 'type' => CRM_Utils_Type
::T_INT
,
259 'title' => ts('Phone Type'),
260 'description' => ts('Which type of phone does this number belongs.'),
262 'where' => 'civicrm_phone.phone_type_id',
263 'headerPattern' => '',
265 'table_name' => 'civicrm_phone',
267 'bao' => 'CRM_Core_BAO_Phone',
272 'pseudoconstant' => [
273 'optionGroupName' => 'phone_type',
274 'optionEditPath' => 'civicrm/admin/options/phone_type',
278 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
280 return Civi
::$statics[__CLASS__
]['fields'];
284 * Return a mapping from field-name to the corresponding key (as used in fields()).
287 * Array(string $name => string $uniqueName).
289 public static function &fieldKeys() {
290 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
291 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
293 return Civi
::$statics[__CLASS__
]['fieldKeys'];
297 * Returns the names of this table
301 public static function getTableName() {
302 return self
::$_tableName;
306 * Returns if this table needs to be logged
310 public function getLog() {
315 * Returns the list of fields that can be imported
317 * @param bool $prefix
321 public static function &import($prefix = FALSE) {
322 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'phone', $prefix, []);
327 * Returns the list of fields that can be exported
329 * @param bool $prefix
333 public static function &export($prefix = FALSE) {
334 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'phone', $prefix, []);
339 * Returns the list of indices
341 * @param bool $localize
345 public static function indices($localize = TRUE) {
347 'index_location_type' => [
348 'name' => 'index_location_type',
350 0 => 'location_type_id',
352 'localizable' => FALSE,
353 'sig' => 'civicrm_phone::0::location_type_id',
355 'index_is_primary' => [
356 'name' => 'index_is_primary',
360 'localizable' => FALSE,
361 'sig' => 'civicrm_phone::0::is_primary',
363 'index_is_billing' => [
364 'name' => 'index_is_billing',
368 'localizable' => FALSE,
369 'sig' => 'civicrm_phone::0::is_billing',
371 'UI_mobile_provider_id' => [
372 'name' => 'UI_mobile_provider_id',
374 0 => 'mobile_provider_id',
376 'localizable' => FALSE,
377 'sig' => 'civicrm_phone::0::mobile_provider_id',
379 'index_phone_numeric' => [
380 'name' => 'index_phone_numeric',
382 0 => 'phone_numeric',
384 'localizable' => FALSE,
385 'sig' => 'civicrm_phone::0::phone_numeric',
388 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;