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:dab6fdaa9d622daab580b32ae1172bc7)
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';
18 const COMPONENT
= 'CiviCampaign';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_campaign';
28 * Icon associated with this entity.
32 public static $_icon = 'fa-bullhorn';
35 * Field to show when displaying a record.
39 public static $_labelField = 'title';
42 * Should CiviCRM log any modifications to this table in the civicrm_log table.
46 public static $_log = FALSE;
49 * Paths for accessing this entity in the UI.
53 protected static $_paths = [
54 'add' => 'civicrm/campaign/add?reset=1',
55 'update' => 'civicrm/campaign/add?reset=1&action=update&id=[id]',
56 'delete' => 'civicrm/campaign/add?reset=1&action=delete&id=[id]',
62 * @var int|string|null
63 * (SQL type: int unsigned)
64 * Note that values will be retrieved from the database as a string.
69 * Name of the Campaign.
72 * (SQL type: varchar(255))
73 * Note that values will be retrieved from the database as a string.
78 * Title of the Campaign.
81 * (SQL type: varchar(255))
82 * Note that values will be retrieved from the database as a string.
87 * Full description of Campaign.
91 * Note that values will be retrieved from the database as a string.
96 * Date and time that Campaign starts.
99 * (SQL type: datetime)
100 * Note that values will be retrieved from the database as a string.
105 * Date and time that Campaign ends.
108 * (SQL type: datetime)
109 * Note that values will be retrieved from the database as a string.
114 * Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type
116 * @var int|string|null
117 * (SQL type: int unsigned)
118 * Note that values will be retrieved from the database as a string.
120 public $campaign_type_id;
123 * Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status
125 * @var int|string|null
126 * (SQL type: int unsigned)
127 * Note that values will be retrieved from the database as a string.
132 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
135 * (SQL type: varchar(32))
136 * Note that values will be retrieved from the database as a string.
138 public $external_identifier;
141 * Optional parent id for this Campaign.
143 * @var int|string|null
144 * (SQL type: int unsigned)
145 * Note that values will be retrieved from the database as a string.
150 * Is this Campaign enabled or disabled/cancelled?
152 * @var bool|string|null
153 * (SQL type: tinyint)
154 * Note that values will be retrieved from the database as a string.
159 * FK to civicrm_contact, who created this Campaign.
161 * @var int|string|null
162 * (SQL type: int unsigned)
163 * Note that values will be retrieved from the database as a string.
168 * Date and time that Campaign was created.
171 * (SQL type: datetime)
172 * Note that values will be retrieved from the database as a string.
174 public $created_date;
177 * FK to civicrm_contact, who recently edited this Campaign.
179 * @var int|string|null
180 * (SQL type: int unsigned)
181 * Note that values will be retrieved from the database as a string.
183 public $last_modified_id;
186 * Date and time that Campaign was edited last time.
189 * (SQL type: datetime)
190 * Note that values will be retrieved from the database as a string.
192 public $last_modified_date;
195 * General goals for Campaign.
199 * Note that values will be retrieved from the database as a string.
201 public $goal_general;
204 * The target revenue for this campaign.
206 * @var float|string|null
207 * (SQL type: decimal(20,2))
208 * Note that values will be retrieved from the database as a string.
210 public $goal_revenue;
215 public function __construct() {
216 $this->__table
= 'civicrm_campaign';
217 parent
::__construct();
221 * Returns localized title of this entity.
223 * @param bool $plural
224 * Whether to return the plural version of the title.
226 public static function getEntityTitle($plural = FALSE) {
227 return $plural ?
ts('Campaigns') : ts('Campaign');
231 * Returns user-friendly description of this entity.
235 public static function getEntityDescription() {
236 return ts('Campaigns link activities, contributions, mailings, etc. that share a programmatic goal.');
240 * Returns foreign keys and entity references.
243 * [CRM_Core_Reference_Interface]
245 public static function getReferenceColumns() {
246 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
247 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
248 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_campaign', 'id');
249 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
250 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
251 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
253 return Civi
::$statics[__CLASS__
]['links'];
257 * Returns all the column names of this table
261 public static function &fields() {
262 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
263 Civi
::$statics[__CLASS__
]['fields'] = [
266 'type' => CRM_Utils_Type
::T_INT
,
267 'title' => ts('Campaign ID'),
268 'description' => ts('Unique Campaign ID.'),
271 'where' => 'civicrm_campaign.id',
273 'table_name' => 'civicrm_campaign',
274 'entity' => 'Campaign',
275 'bao' => 'CRM_Campaign_BAO_Campaign',
285 'type' => CRM_Utils_Type
::T_STRING
,
286 'title' => ts('Campaign Name'),
287 'description' => ts('Name of the Campaign.'),
290 'size' => CRM_Utils_Type
::HUGE
,
292 'where' => 'civicrm_campaign.name',
294 'table_name' => 'civicrm_campaign',
295 'entity' => 'Campaign',
296 'bao' => 'CRM_Campaign_BAO_Campaign',
305 'type' => CRM_Utils_Type
::T_STRING
,
306 'title' => ts('Campaign Title'),
307 'description' => ts('Title of the Campaign.'),
309 'size' => CRM_Utils_Type
::HUGE
,
311 'where' => 'civicrm_campaign.title',
313 'table_name' => 'civicrm_campaign',
314 'entity' => 'Campaign',
315 'bao' => 'CRM_Campaign_BAO_Campaign',
323 'name' => 'description',
324 'type' => CRM_Utils_Type
::T_TEXT
,
325 'title' => ts('Campaign Description'),
326 'description' => ts('Full description of Campaign.'),
329 'where' => 'civicrm_campaign.description',
330 'table_name' => 'civicrm_campaign',
331 'entity' => 'Campaign',
332 'bao' => 'CRM_Campaign_BAO_Campaign',
335 'type' => 'TextArea',
340 'name' => 'start_date',
341 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
342 'title' => ts('Campaign Start Date'),
343 'description' => ts('Date and time that Campaign starts.'),
345 'where' => 'civicrm_campaign.start_date',
346 'headerPattern' => '/^start|(s(tart\s)?date)$/i',
348 'table_name' => 'civicrm_campaign',
349 'entity' => 'Campaign',
350 'bao' => 'CRM_Campaign_BAO_Campaign',
353 'type' => 'Select Date',
354 'formatType' => 'activityDateTime',
359 'name' => 'end_date',
360 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
361 'title' => ts('Campaign End Date'),
362 'description' => ts('Date and time that Campaign ends.'),
364 'where' => 'civicrm_campaign.end_date',
365 'headerPattern' => '/^end|(e(nd\s)?date)$/i',
367 'table_name' => 'civicrm_campaign',
368 'entity' => 'Campaign',
369 'bao' => 'CRM_Campaign_BAO_Campaign',
372 'type' => 'Select Date',
373 'formatType' => 'activityDateTime',
377 'campaign_type_id' => [
378 'name' => 'campaign_type_id',
379 'type' => CRM_Utils_Type
::T_INT
,
380 'title' => ts('Campaign Type'),
381 'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'),
383 'where' => 'civicrm_campaign.campaign_type_id',
386 'table_name' => 'civicrm_campaign',
387 'entity' => 'Campaign',
388 'bao' => 'CRM_Campaign_BAO_Campaign',
393 'pseudoconstant' => [
394 'optionGroupName' => 'campaign_type',
395 'optionEditPath' => 'civicrm/admin/options/campaign_type',
400 'name' => 'status_id',
401 'type' => CRM_Utils_Type
::T_INT
,
402 'title' => ts('Campaign Status'),
403 'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'),
405 'where' => 'civicrm_campaign.status_id',
408 'table_name' => 'civicrm_campaign',
409 'entity' => 'Campaign',
410 'bao' => 'CRM_Campaign_BAO_Campaign',
415 'pseudoconstant' => [
416 'optionGroupName' => 'campaign_status',
417 'optionEditPath' => 'civicrm/admin/options/campaign_status',
421 'external_identifier' => [
422 'name' => 'external_identifier',
423 'type' => CRM_Utils_Type
::T_STRING
,
424 'title' => ts('Campaign External ID'),
425 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
427 'size' => CRM_Utils_Type
::MEDIUM
,
429 'where' => 'civicrm_campaign.external_identifier',
430 'headerPattern' => '/external\s?id/i',
431 'dataPattern' => '/^\d{11,}$/',
433 'table_name' => 'civicrm_campaign',
434 'entity' => 'Campaign',
435 'bao' => 'CRM_Campaign_BAO_Campaign',
443 'name' => 'parent_id',
444 'type' => CRM_Utils_Type
::T_INT
,
445 'title' => ts('Parent Campaign ID'),
446 'description' => ts('Optional parent id for this Campaign.'),
448 'where' => 'civicrm_campaign.parent_id',
451 'table_name' => 'civicrm_campaign',
452 'entity' => 'Campaign',
453 'bao' => 'CRM_Campaign_BAO_Campaign',
455 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
457 'type' => 'EntityRef',
458 'label' => ts("Parent Campaign"),
463 'name' => 'is_active',
464 'type' => CRM_Utils_Type
::T_BOOLEAN
,
465 'title' => ts('Is Campaign Active?'),
466 'description' => ts('Is this Campaign enabled or disabled/cancelled?'),
467 'where' => 'civicrm_campaign.is_active',
469 'table_name' => 'civicrm_campaign',
470 'entity' => 'Campaign',
471 'bao' => 'CRM_Campaign_BAO_Campaign',
474 'type' => 'CheckBox',
479 'name' => 'created_id',
480 'type' => CRM_Utils_Type
::T_INT
,
481 'title' => ts('Created By Contact ID'),
482 'description' => ts('FK to civicrm_contact, who created this Campaign.'),
483 'where' => 'civicrm_campaign.created_id',
484 'table_name' => 'civicrm_campaign',
485 'entity' => 'Campaign',
486 'bao' => 'CRM_Campaign_BAO_Campaign',
488 'FKClassName' => 'CRM_Contact_DAO_Contact',
490 'label' => ts("Created By"),
495 'name' => 'created_date',
496 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
497 'title' => ts('Campaign Created Date'),
498 'description' => ts('Date and time that Campaign was created.'),
499 'where' => 'civicrm_campaign.created_date',
500 'table_name' => 'civicrm_campaign',
501 'entity' => 'Campaign',
502 'bao' => 'CRM_Campaign_BAO_Campaign',
505 'type' => 'Select Date',
506 'formatType' => 'activityDateTime',
510 'last_modified_id' => [
511 'name' => 'last_modified_id',
512 'type' => CRM_Utils_Type
::T_INT
,
513 'title' => ts('Modified By Contact ID'),
514 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
515 'where' => 'civicrm_campaign.last_modified_id',
516 'table_name' => 'civicrm_campaign',
517 'entity' => 'Campaign',
518 'bao' => 'CRM_Campaign_BAO_Campaign',
520 'FKClassName' => 'CRM_Contact_DAO_Contact',
522 'label' => ts("Modified By"),
526 'last_modified_date' => [
527 'name' => 'last_modified_date',
528 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
529 'title' => ts('Campaign Modified Date'),
530 'description' => ts('Date and time that Campaign was edited last time.'),
531 'where' => 'civicrm_campaign.last_modified_date',
532 'table_name' => 'civicrm_campaign',
533 'entity' => 'Campaign',
534 'bao' => 'CRM_Campaign_BAO_Campaign',
539 'name' => 'goal_general',
540 'type' => CRM_Utils_Type
::T_TEXT
,
541 'title' => ts('Campaign Goals'),
542 'description' => ts('General goals for Campaign.'),
543 'where' => 'civicrm_campaign.goal_general',
544 'table_name' => 'civicrm_campaign',
545 'entity' => 'Campaign',
546 'bao' => 'CRM_Campaign_BAO_Campaign',
549 'type' => 'RichTextEditor',
554 'name' => 'goal_revenue',
555 'type' => CRM_Utils_Type
::T_MONEY
,
556 'title' => ts('Goal Revenue'),
557 'description' => ts('The target revenue for this campaign.'),
562 'where' => 'civicrm_campaign.goal_revenue',
563 'table_name' => 'civicrm_campaign',
564 'entity' => 'Campaign',
565 'bao' => 'CRM_Campaign_BAO_Campaign',
569 'label' => ts("Goal Revenue"),
574 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
576 return Civi
::$statics[__CLASS__
]['fields'];
580 * Return a mapping from field-name to the corresponding key (as used in fields()).
583 * Array(string $name => string $uniqueName).
585 public static function &fieldKeys() {
586 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
587 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
589 return Civi
::$statics[__CLASS__
]['fieldKeys'];
593 * Returns the names of this table
597 public static function getTableName() {
598 return self
::$_tableName;
602 * Returns if this table needs to be logged
606 public function getLog() {
611 * Returns the list of fields that can be imported
613 * @param bool $prefix
617 public static function &import($prefix = FALSE) {
618 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'campaign', $prefix, []);
623 * Returns the list of fields that can be exported
625 * @param bool $prefix
629 public static function &export($prefix = FALSE) {
630 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'campaign', $prefix, []);
635 * Returns the list of indices
637 * @param bool $localize
641 public static function indices($localize = TRUE) {
643 'UI_campaign_name' => [
644 'name' => 'UI_campaign_name',
648 'localizable' => FALSE,
649 'sig' => 'civicrm_campaign::0::name',
651 'UI_campaign_type_id' => [
652 'name' => 'UI_campaign_type_id',
654 0 => 'campaign_type_id',
656 'localizable' => FALSE,
657 'sig' => 'civicrm_campaign::0::campaign_type_id',
659 'UI_campaign_status_id' => [
660 'name' => 'UI_campaign_status_id',
664 'localizable' => FALSE,
665 'sig' => 'civicrm_campaign::0::status_id',
667 'UI_external_identifier' => [
668 'name' => 'UI_external_identifier',
670 0 => 'external_identifier',
672 'localizable' => FALSE,
674 'sig' => 'civicrm_campaign::1::external_identifier',
677 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;