5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Campaign/Campaign.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:cfa77579eb9b91b31b6c5618b52c6e87)
13 * Database access object for the Campaign entity.
15 class CRM_Campaign_DAO_Campaign
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '3.3';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_campaign';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-bullhorn';
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = FALSE;
48 * Name of the Campaign.
55 * Title of the Campaign.
62 * Full description of Campaign.
69 * Date and time that Campaign starts.
76 * Date and time that Campaign ends.
83 * Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type
87 public $campaign_type_id;
90 * Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status
97 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
101 public $external_identifier;
104 * Optional parent id for this Campaign.
111 * Is this Campaign enabled or disabled/cancelled?
118 * FK to civicrm_contact, who created this Campaign.
125 * Date and time that Campaign was created.
129 public $created_date;
132 * FK to civicrm_contact, who recently edited this Campaign.
136 public $last_modified_id;
139 * Date and time that Campaign was edited last time.
143 public $last_modified_date;
146 * General goals for Campaign.
150 public $goal_general;
153 * The target revenue for this campaign.
157 public $goal_revenue;
162 public function __construct() {
163 $this->__table
= 'civicrm_campaign';
164 parent
::__construct();
168 * Returns localized title of this entity.
170 public static function getEntityTitle() {
171 return ts('Campaigns');
175 * Returns foreign keys and entity references.
178 * [CRM_Core_Reference_Interface]
180 public static function getReferenceColumns() {
181 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
182 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
183 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_campaign', 'id');
184 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
185 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
186 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
188 return Civi
::$statics[__CLASS__
]['links'];
192 * Returns all the column names of this table
196 public static function &fields() {
197 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
198 Civi
::$statics[__CLASS__
]['fields'] = [
201 'type' => CRM_Utils_Type
::T_INT
,
202 'title' => ts('Campaign ID'),
203 'description' => ts('Unique Campaign ID.'),
206 'where' => 'civicrm_campaign.id',
208 'table_name' => 'civicrm_campaign',
209 'entity' => 'Campaign',
210 'bao' => 'CRM_Campaign_BAO_Campaign',
216 'type' => CRM_Utils_Type
::T_STRING
,
217 'title' => ts('Campaign Name'),
218 'description' => ts('Name of the Campaign.'),
221 'size' => CRM_Utils_Type
::HUGE
,
223 'where' => 'civicrm_campaign.name',
225 'table_name' => 'civicrm_campaign',
226 'entity' => 'Campaign',
227 'bao' => 'CRM_Campaign_BAO_Campaign',
236 'type' => CRM_Utils_Type
::T_STRING
,
237 'title' => ts('Campaign Title'),
238 'description' => ts('Title of the Campaign.'),
240 'size' => CRM_Utils_Type
::HUGE
,
242 'where' => 'civicrm_campaign.title',
244 'table_name' => 'civicrm_campaign',
245 'entity' => 'Campaign',
246 'bao' => 'CRM_Campaign_BAO_Campaign',
254 'name' => 'description',
255 'type' => CRM_Utils_Type
::T_TEXT
,
256 'title' => ts('Campaign Description'),
257 'description' => ts('Full description of Campaign.'),
260 'where' => 'civicrm_campaign.description',
261 'table_name' => 'civicrm_campaign',
262 'entity' => 'Campaign',
263 'bao' => 'CRM_Campaign_BAO_Campaign',
266 'type' => 'TextArea',
271 'name' => 'start_date',
272 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
273 'title' => ts('Campaign Start Date'),
274 'description' => ts('Date and time that Campaign starts.'),
276 'where' => 'civicrm_campaign.start_date',
277 'headerPattern' => '/^start|(s(tart\s)?date)$/i',
279 'table_name' => 'civicrm_campaign',
280 'entity' => 'Campaign',
281 'bao' => 'CRM_Campaign_BAO_Campaign',
284 'type' => 'Select Date',
285 'formatType' => 'activityDateTime',
290 'name' => 'end_date',
291 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
292 'title' => ts('Campaign End Date'),
293 'description' => ts('Date and time that Campaign ends.'),
295 'where' => 'civicrm_campaign.end_date',
296 'headerPattern' => '/^end|(e(nd\s)?date)$/i',
298 'table_name' => 'civicrm_campaign',
299 'entity' => 'Campaign',
300 'bao' => 'CRM_Campaign_BAO_Campaign',
303 'type' => 'Select Date',
304 'formatType' => 'activityDateTime',
308 'campaign_type_id' => [
309 'name' => 'campaign_type_id',
310 'type' => CRM_Utils_Type
::T_INT
,
311 'title' => ts('Campaign Type'),
312 'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'),
314 'where' => 'civicrm_campaign.campaign_type_id',
317 'table_name' => 'civicrm_campaign',
318 'entity' => 'Campaign',
319 'bao' => 'CRM_Campaign_BAO_Campaign',
324 'pseudoconstant' => [
325 'optionGroupName' => 'campaign_type',
326 'optionEditPath' => 'civicrm/admin/options/campaign_type',
331 'name' => 'status_id',
332 'type' => CRM_Utils_Type
::T_INT
,
333 'title' => ts('Campaign Status'),
334 'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'),
336 'where' => 'civicrm_campaign.status_id',
339 'table_name' => 'civicrm_campaign',
340 'entity' => 'Campaign',
341 'bao' => 'CRM_Campaign_BAO_Campaign',
346 'pseudoconstant' => [
347 'optionGroupName' => 'campaign_status',
348 'optionEditPath' => 'civicrm/admin/options/campaign_status',
352 'external_identifier' => [
353 'name' => 'external_identifier',
354 'type' => CRM_Utils_Type
::T_STRING
,
355 'title' => ts('Campaign External ID'),
356 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
358 'size' => CRM_Utils_Type
::MEDIUM
,
360 'where' => 'civicrm_campaign.external_identifier',
361 'headerPattern' => '/external\s?id/i',
362 'dataPattern' => '/^\d{11,}$/',
364 'table_name' => 'civicrm_campaign',
365 'entity' => 'Campaign',
366 'bao' => 'CRM_Campaign_BAO_Campaign',
374 'name' => 'parent_id',
375 'type' => CRM_Utils_Type
::T_INT
,
376 'title' => ts('Parent Campaign'),
377 'description' => ts('Optional parent id for this Campaign.'),
379 'where' => 'civicrm_campaign.parent_id',
382 'table_name' => 'civicrm_campaign',
383 'entity' => 'Campaign',
384 'bao' => 'CRM_Campaign_BAO_Campaign',
386 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
388 'type' => 'EntityRef',
393 'name' => 'is_active',
394 'type' => CRM_Utils_Type
::T_BOOLEAN
,
395 'title' => ts('Is Campaign Active?'),
396 'description' => ts('Is this Campaign enabled or disabled/cancelled?'),
397 'where' => 'civicrm_campaign.is_active',
399 'table_name' => 'civicrm_campaign',
400 'entity' => 'Campaign',
401 'bao' => 'CRM_Campaign_BAO_Campaign',
404 'type' => 'CheckBox',
409 'name' => 'created_id',
410 'type' => CRM_Utils_Type
::T_INT
,
411 'title' => ts('Campaign Created By'),
412 'description' => ts('FK to civicrm_contact, who created this Campaign.'),
413 'where' => 'civicrm_campaign.created_id',
414 'table_name' => 'civicrm_campaign',
415 'entity' => 'Campaign',
416 'bao' => 'CRM_Campaign_BAO_Campaign',
418 'FKClassName' => 'CRM_Contact_DAO_Contact',
422 'name' => 'created_date',
423 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
424 'title' => ts('Campaign Created Date'),
425 'description' => ts('Date and time that Campaign was created.'),
426 'where' => 'civicrm_campaign.created_date',
427 'table_name' => 'civicrm_campaign',
428 'entity' => 'Campaign',
429 'bao' => 'CRM_Campaign_BAO_Campaign',
432 'type' => 'Select Date',
433 'formatType' => 'activityDateTime',
437 'last_modified_id' => [
438 'name' => 'last_modified_id',
439 'type' => CRM_Utils_Type
::T_INT
,
440 'title' => ts('Campaign Modified By'),
441 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
442 'where' => 'civicrm_campaign.last_modified_id',
443 'table_name' => 'civicrm_campaign',
444 'entity' => 'Campaign',
445 'bao' => 'CRM_Campaign_BAO_Campaign',
447 'FKClassName' => 'CRM_Contact_DAO_Contact',
450 'last_modified_date' => [
451 'name' => 'last_modified_date',
452 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
453 'title' => ts('Campaign Modified Date'),
454 'description' => ts('Date and time that Campaign was edited last time.'),
455 'where' => 'civicrm_campaign.last_modified_date',
456 'table_name' => 'civicrm_campaign',
457 'entity' => 'Campaign',
458 'bao' => 'CRM_Campaign_BAO_Campaign',
463 'name' => 'goal_general',
464 'type' => CRM_Utils_Type
::T_TEXT
,
465 'title' => ts('Campaign Goals'),
466 'description' => ts('General goals for Campaign.'),
467 'where' => 'civicrm_campaign.goal_general',
468 'table_name' => 'civicrm_campaign',
469 'entity' => 'Campaign',
470 'bao' => 'CRM_Campaign_BAO_Campaign',
473 'type' => 'RichTextEditor',
478 'name' => 'goal_revenue',
479 'type' => CRM_Utils_Type
::T_MONEY
,
480 'title' => ts('Goal Revenue'),
481 'description' => ts('The target revenue for this campaign.'),
486 'where' => 'civicrm_campaign.goal_revenue',
487 'table_name' => 'civicrm_campaign',
488 'entity' => 'Campaign',
489 'bao' => 'CRM_Campaign_BAO_Campaign',
497 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
499 return Civi
::$statics[__CLASS__
]['fields'];
503 * Return a mapping from field-name to the corresponding key (as used in fields()).
506 * Array(string $name => string $uniqueName).
508 public static function &fieldKeys() {
509 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
510 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
512 return Civi
::$statics[__CLASS__
]['fieldKeys'];
516 * Returns the names of this table
520 public static function getTableName() {
521 return self
::$_tableName;
525 * Returns if this table needs to be logged
529 public function getLog() {
534 * Returns the list of fields that can be imported
536 * @param bool $prefix
540 public static function &import($prefix = FALSE) {
541 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'campaign', $prefix, []);
546 * Returns the list of fields that can be exported
548 * @param bool $prefix
552 public static function &export($prefix = FALSE) {
553 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'campaign', $prefix, []);
558 * Returns the list of indices
560 * @param bool $localize
564 public static function indices($localize = TRUE) {
566 'UI_campaign_type_id' => [
567 'name' => 'UI_campaign_type_id',
569 0 => 'campaign_type_id',
571 'localizable' => FALSE,
572 'sig' => 'civicrm_campaign::0::campaign_type_id',
574 'UI_campaign_status_id' => [
575 'name' => 'UI_campaign_status_id',
579 'localizable' => FALSE,
580 'sig' => 'civicrm_campaign::0::status_id',
582 'UI_external_identifier' => [
583 'name' => 'UI_external_identifier',
585 0 => 'external_identifier',
587 'localizable' => FALSE,
589 'sig' => 'civicrm_campaign::1::external_identifier',
592 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;