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:cad676be961a58037e4c460be6f9a450)
13 * Database access object for the Campaign entity.
15 class CRM_Campaign_DAO_Campaign
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_campaign';
25 * Icon associated with this entity.
29 public static $_icon = 'fa-bullhorn';
32 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 public static $_log = FALSE;
46 * Name of the Campaign.
53 * Title of the Campaign.
60 * Full description of Campaign.
67 * Date and time that Campaign starts.
74 * Date and time that Campaign ends.
81 * Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type
85 public $campaign_type_id;
88 * Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status
95 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
99 public $external_identifier;
102 * Optional parent id for this Campaign.
109 * Is this Campaign enabled or disabled/cancelled?
116 * FK to civicrm_contact, who created this Campaign.
123 * Date and time that Campaign was created.
127 public $created_date;
130 * FK to civicrm_contact, who recently edited this Campaign.
134 public $last_modified_id;
137 * Date and time that Campaign was edited last time.
141 public $last_modified_date;
144 * General goals for Campaign.
148 public $goal_general;
151 * The target revenue for this campaign.
155 public $goal_revenue;
160 public function __construct() {
161 $this->__table
= 'civicrm_campaign';
162 parent
::__construct();
166 * Returns localized title of this entity.
168 public static function getEntityTitle() {
169 return ts('Campaigns');
173 * Returns foreign keys and entity references.
176 * [CRM_Core_Reference_Interface]
178 public static function getReferenceColumns() {
179 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
180 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
181 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_campaign', 'id');
182 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
183 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
184 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
186 return Civi
::$statics[__CLASS__
]['links'];
190 * Returns all the column names of this table
194 public static function &fields() {
195 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
196 Civi
::$statics[__CLASS__
]['fields'] = [
199 'type' => CRM_Utils_Type
::T_INT
,
200 'title' => ts('Campaign ID'),
201 'description' => ts('Unique Campaign ID.'),
204 'where' => 'civicrm_campaign.id',
206 'table_name' => 'civicrm_campaign',
207 'entity' => 'Campaign',
208 'bao' => 'CRM_Campaign_BAO_Campaign',
214 'type' => CRM_Utils_Type
::T_STRING
,
215 'title' => ts('Campaign Name'),
216 'description' => ts('Name of the Campaign.'),
219 'size' => CRM_Utils_Type
::HUGE
,
221 'where' => 'civicrm_campaign.name',
223 'table_name' => 'civicrm_campaign',
224 'entity' => 'Campaign',
225 'bao' => 'CRM_Campaign_BAO_Campaign',
234 'type' => CRM_Utils_Type
::T_STRING
,
235 'title' => ts('Campaign Title'),
236 'description' => ts('Title of the Campaign.'),
238 'size' => CRM_Utils_Type
::HUGE
,
240 'where' => 'civicrm_campaign.title',
242 'table_name' => 'civicrm_campaign',
243 'entity' => 'Campaign',
244 'bao' => 'CRM_Campaign_BAO_Campaign',
252 'name' => 'description',
253 'type' => CRM_Utils_Type
::T_TEXT
,
254 'title' => ts('Campaign Description'),
255 'description' => ts('Full description of Campaign.'),
258 'where' => 'civicrm_campaign.description',
259 'table_name' => 'civicrm_campaign',
260 'entity' => 'Campaign',
261 'bao' => 'CRM_Campaign_BAO_Campaign',
264 'type' => 'TextArea',
269 'name' => 'start_date',
270 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
271 'title' => ts('Campaign Start Date'),
272 'description' => ts('Date and time that Campaign starts.'),
274 'where' => 'civicrm_campaign.start_date',
275 'headerPattern' => '/^start|(s(tart\s)?date)$/i',
277 'table_name' => 'civicrm_campaign',
278 'entity' => 'Campaign',
279 'bao' => 'CRM_Campaign_BAO_Campaign',
282 'type' => 'Select Date',
287 'name' => 'end_date',
288 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
289 'title' => ts('Campaign End Date'),
290 'description' => ts('Date and time that Campaign ends.'),
292 'where' => 'civicrm_campaign.end_date',
293 'headerPattern' => '/^end|(e(nd\s)?date)$/i',
295 'table_name' => 'civicrm_campaign',
296 'entity' => 'Campaign',
297 'bao' => 'CRM_Campaign_BAO_Campaign',
300 'type' => 'Select Date',
304 'campaign_type_id' => [
305 'name' => 'campaign_type_id',
306 'type' => CRM_Utils_Type
::T_INT
,
307 'title' => ts('Campaign Type'),
308 'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'),
310 'where' => 'civicrm_campaign.campaign_type_id',
313 'table_name' => 'civicrm_campaign',
314 'entity' => 'Campaign',
315 'bao' => 'CRM_Campaign_BAO_Campaign',
320 'pseudoconstant' => [
321 'optionGroupName' => 'campaign_type',
322 'optionEditPath' => 'civicrm/admin/options/campaign_type',
327 'name' => 'status_id',
328 'type' => CRM_Utils_Type
::T_INT
,
329 'title' => ts('Campaign Status'),
330 'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'),
332 'where' => 'civicrm_campaign.status_id',
335 'table_name' => 'civicrm_campaign',
336 'entity' => 'Campaign',
337 'bao' => 'CRM_Campaign_BAO_Campaign',
342 'pseudoconstant' => [
343 'optionGroupName' => 'campaign_status',
344 'optionEditPath' => 'civicrm/admin/options/campaign_status',
348 'external_identifier' => [
349 'name' => 'external_identifier',
350 'type' => CRM_Utils_Type
::T_STRING
,
351 'title' => ts('Campaign External ID'),
352 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
354 'size' => CRM_Utils_Type
::MEDIUM
,
356 'where' => 'civicrm_campaign.external_identifier',
357 'headerPattern' => '/external\s?id/i',
358 'dataPattern' => '/^\d{11,}$/',
360 'table_name' => 'civicrm_campaign',
361 'entity' => 'Campaign',
362 'bao' => 'CRM_Campaign_BAO_Campaign',
370 'name' => 'parent_id',
371 'type' => CRM_Utils_Type
::T_INT
,
372 'title' => ts('Parent Campaign'),
373 'description' => ts('Optional parent id for this Campaign.'),
375 'where' => 'civicrm_campaign.parent_id',
378 'table_name' => 'civicrm_campaign',
379 'entity' => 'Campaign',
380 'bao' => 'CRM_Campaign_BAO_Campaign',
382 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
384 'type' => 'EntityRef',
389 'name' => 'is_active',
390 'type' => CRM_Utils_Type
::T_BOOLEAN
,
391 'title' => ts('Is Campaign Active?'),
392 'description' => ts('Is this Campaign enabled or disabled/cancelled?'),
393 'where' => 'civicrm_campaign.is_active',
395 'table_name' => 'civicrm_campaign',
396 'entity' => 'Campaign',
397 'bao' => 'CRM_Campaign_BAO_Campaign',
400 'type' => 'CheckBox',
405 'name' => 'created_id',
406 'type' => CRM_Utils_Type
::T_INT
,
407 'title' => ts('Campaign Created By'),
408 'description' => ts('FK to civicrm_contact, who created this Campaign.'),
409 'where' => 'civicrm_campaign.created_id',
410 'table_name' => 'civicrm_campaign',
411 'entity' => 'Campaign',
412 'bao' => 'CRM_Campaign_BAO_Campaign',
414 'FKClassName' => 'CRM_Contact_DAO_Contact',
418 'name' => 'created_date',
419 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
420 'title' => ts('Campaign Created Date'),
421 'description' => ts('Date and time that Campaign was created.'),
422 'where' => 'civicrm_campaign.created_date',
423 'table_name' => 'civicrm_campaign',
424 'entity' => 'Campaign',
425 'bao' => 'CRM_Campaign_BAO_Campaign',
428 'type' => 'Select Date',
432 'last_modified_id' => [
433 'name' => 'last_modified_id',
434 'type' => CRM_Utils_Type
::T_INT
,
435 'title' => ts('Campaign Modified By'),
436 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
437 'where' => 'civicrm_campaign.last_modified_id',
438 'table_name' => 'civicrm_campaign',
439 'entity' => 'Campaign',
440 'bao' => 'CRM_Campaign_BAO_Campaign',
442 'FKClassName' => 'CRM_Contact_DAO_Contact',
445 'last_modified_date' => [
446 'name' => 'last_modified_date',
447 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
448 'title' => ts('Campaign Modified Date'),
449 'description' => ts('Date and time that Campaign was edited last time.'),
450 'where' => 'civicrm_campaign.last_modified_date',
451 'table_name' => 'civicrm_campaign',
452 'entity' => 'Campaign',
453 'bao' => 'CRM_Campaign_BAO_Campaign',
458 'name' => 'goal_general',
459 'type' => CRM_Utils_Type
::T_TEXT
,
460 'title' => ts('Campaign Goals'),
461 'description' => ts('General goals for Campaign.'),
462 'where' => 'civicrm_campaign.goal_general',
463 'table_name' => 'civicrm_campaign',
464 'entity' => 'Campaign',
465 'bao' => 'CRM_Campaign_BAO_Campaign',
468 'type' => 'RichTextEditor',
473 'name' => 'goal_revenue',
474 'type' => CRM_Utils_Type
::T_MONEY
,
475 'title' => ts('Goal Revenue'),
476 'description' => ts('The target revenue for this campaign.'),
481 'where' => 'civicrm_campaign.goal_revenue',
482 'table_name' => 'civicrm_campaign',
483 'entity' => 'Campaign',
484 'bao' => 'CRM_Campaign_BAO_Campaign',
492 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
494 return Civi
::$statics[__CLASS__
]['fields'];
498 * Return a mapping from field-name to the corresponding key (as used in fields()).
501 * Array(string $name => string $uniqueName).
503 public static function &fieldKeys() {
504 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
505 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
507 return Civi
::$statics[__CLASS__
]['fieldKeys'];
511 * Returns the names of this table
515 public static function getTableName() {
516 return self
::$_tableName;
520 * Returns if this table needs to be logged
524 public function getLog() {
529 * Returns the list of fields that can be imported
531 * @param bool $prefix
535 public static function &import($prefix = FALSE) {
536 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'campaign', $prefix, []);
541 * Returns the list of fields that can be exported
543 * @param bool $prefix
547 public static function &export($prefix = FALSE) {
548 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'campaign', $prefix, []);
553 * Returns the list of indices
555 * @param bool $localize
559 public static function indices($localize = TRUE) {
561 'UI_campaign_type_id' => [
562 'name' => 'UI_campaign_type_id',
564 0 => 'campaign_type_id',
566 'localizable' => FALSE,
567 'sig' => 'civicrm_campaign::0::campaign_type_id',
569 'UI_campaign_status_id' => [
570 'name' => 'UI_campaign_status_id',
574 'localizable' => FALSE,
575 'sig' => 'civicrm_campaign::0::status_id',
577 'UI_external_identifier' => [
578 'name' => 'UI_external_identifier',
580 0 => 'external_identifier',
582 'localizable' => FALSE,
584 'sig' => 'civicrm_campaign::1::external_identifier',
587 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;