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:661faad4886dd1a40784d465b906f447)
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' => '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' => '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' => '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' => 'Is this the primary phone for this contact and location.',
177 'table_name' => 'civicrm_phone',
179 'bao' => 'CRM_Core_BAO_Phone',
183 'name' => 'is_billing',
184 'type' => CRM_Utils_Type
::T_BOOLEAN
,
185 'title' => ts('Is Billing Phone'),
186 'description' => 'Is this the billing?',
187 'table_name' => 'civicrm_phone',
189 'bao' => 'CRM_Core_BAO_Phone',
192 'mobile_provider_id' => [
193 'name' => 'mobile_provider_id',
194 'type' => CRM_Utils_Type
::T_INT
,
195 'title' => ts('Mobile Provider'),
196 'description' => 'Which Mobile Provider does this phone belong to.',
197 'table_name' => 'civicrm_phone',
199 'bao' => 'CRM_Core_BAO_Phone',
204 'type' => CRM_Utils_Type
::T_STRING
,
205 'title' => ts('Phone'),
206 'description' => 'Complete phone number.',
208 'size' => CRM_Utils_Type
::MEDIUM
,
210 'where' => 'civicrm_phone.phone',
211 'headerPattern' => '/phone/i',
212 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
214 'table_name' => 'civicrm_phone',
216 'bao' => 'CRM_Core_BAO_Phone',
223 'name' => 'phone_ext',
224 'type' => CRM_Utils_Type
::T_STRING
,
225 'title' => ts('Phone Extension'),
226 'description' => 'Optional extension for a phone number.',
230 'where' => 'civicrm_phone.phone_ext',
231 'headerPattern' => '/extension/i',
232 'dataPattern' => '/^\d+$/',
234 'table_name' => 'civicrm_phone',
236 'bao' => 'CRM_Core_BAO_Phone',
243 'name' => 'phone_numeric',
244 'type' => CRM_Utils_Type
::T_STRING
,
245 'title' => ts('Phone Numeric'),
246 'description' => 'Phone number stripped of all whitespace, letters, and punctuation.',
248 'size' => CRM_Utils_Type
::MEDIUM
,
249 'table_name' => 'civicrm_phone',
251 'bao' => 'CRM_Core_BAO_Phone',
255 'name' => 'phone_type_id',
256 'type' => CRM_Utils_Type
::T_INT
,
257 'title' => ts('Phone Type'),
258 'description' => 'Which type of phone does this number belongs.',
259 'table_name' => 'civicrm_phone',
261 'bao' => 'CRM_Core_BAO_Phone',
266 'pseudoconstant' => [
267 'optionGroupName' => 'phone_type',
268 'optionEditPath' => 'civicrm/admin/options/phone_type',
272 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
274 return Civi
::$statics[__CLASS__
]['fields'];
278 * Return a mapping from field-name to the corresponding key (as used in fields()).
281 * Array(string $name => string $uniqueName).
283 public static function &fieldKeys() {
284 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
285 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
287 return Civi
::$statics[__CLASS__
]['fieldKeys'];
291 * Returns the names of this table
295 public static function getTableName() {
296 return self
::$_tableName;
300 * Returns if this table needs to be logged
304 public function getLog() {
309 * Returns the list of fields that can be imported
311 * @param bool $prefix
315 public static function &import($prefix = FALSE) {
316 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'phone', $prefix, []);
321 * Returns the list of fields that can be exported
323 * @param bool $prefix
327 public static function &export($prefix = FALSE) {
328 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'phone', $prefix, []);
333 * Returns the list of indices
335 * @param bool $localize
339 public static function indices($localize = TRUE) {
341 'index_location_type' => [
342 'name' => 'index_location_type',
344 0 => 'location_type_id',
346 'localizable' => FALSE,
347 'sig' => 'civicrm_phone::0::location_type_id',
349 'index_is_primary' => [
350 'name' => 'index_is_primary',
354 'localizable' => FALSE,
355 'sig' => 'civicrm_phone::0::is_primary',
357 'index_is_billing' => [
358 'name' => 'index_is_billing',
362 'localizable' => FALSE,
363 'sig' => 'civicrm_phone::0::is_billing',
365 'UI_mobile_provider_id' => [
366 'name' => 'UI_mobile_provider_id',
368 0 => 'mobile_provider_id',
370 'localizable' => FALSE,
371 'sig' => 'civicrm_phone::0::mobile_provider_id',
373 'index_phone_numeric' => [
374 'name' => 'index_phone_numeric',
376 0 => 'phone_numeric',
378 'localizable' => FALSE,
379 'sig' => 'civicrm_phone::0::phone_numeric',
382 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;