5 * @copyright CiviCRM LLC (c) 2004-2019
7 * Generated from xml/schema/CRM/Campaign/Campaign.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ab19aa73d01b529988c178673fc38d58)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = FALSE;
39 * Name of the Campaign.
46 * Title of the Campaign.
53 * Full description of Campaign.
60 * Date and time that Campaign starts.
67 * Date and time that Campaign ends.
74 * Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type
78 public $campaign_type_id;
81 * Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status
88 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
92 public $external_identifier;
95 * Optional parent id for this Campaign.
102 * Is this Campaign enabled or disabled/cancelled?
109 * FK to civicrm_contact, who created this Campaign.
116 * Date and time that Campaign was created.
120 public $created_date;
123 * FK to civicrm_contact, who recently edited this Campaign.
127 public $last_modified_id;
130 * Date and time that Campaign was edited last time.
134 public $last_modified_date;
137 * General goals for Campaign.
141 public $goal_general;
144 * The target revenue for this campaign.
148 public $goal_revenue;
153 public function __construct() {
154 $this->__table
= 'civicrm_campaign';
155 parent
::__construct();
159 * Returns foreign keys and entity references.
162 * [CRM_Core_Reference_Interface]
164 public static function getReferenceColumns() {
165 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
166 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
167 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_campaign', 'id');
168 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
169 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
170 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
172 return Civi
::$statics[__CLASS__
]['links'];
176 * Returns all the column names of this table
180 public static function &fields() {
181 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
182 Civi
::$statics[__CLASS__
]['fields'] = [
185 'type' => CRM_Utils_Type
::T_INT
,
186 'title' => ts('Campaign ID'),
187 'description' => ts('Unique Campaign ID.'),
190 'where' => 'civicrm_campaign.id',
192 'table_name' => 'civicrm_campaign',
193 'entity' => 'Campaign',
194 'bao' => 'CRM_Campaign_BAO_Campaign',
199 'type' => CRM_Utils_Type
::T_STRING
,
200 'title' => ts('Campaign Name'),
201 'description' => ts('Name of the Campaign.'),
204 'size' => CRM_Utils_Type
::HUGE
,
206 'where' => 'civicrm_campaign.name',
208 'table_name' => 'civicrm_campaign',
209 'entity' => 'Campaign',
210 'bao' => 'CRM_Campaign_BAO_Campaign',
218 'type' => CRM_Utils_Type
::T_STRING
,
219 'title' => ts('Campaign Title'),
220 'description' => ts('Title of the Campaign.'),
222 'size' => CRM_Utils_Type
::HUGE
,
224 'where' => 'civicrm_campaign.title',
226 'table_name' => 'civicrm_campaign',
227 'entity' => 'Campaign',
228 'bao' => 'CRM_Campaign_BAO_Campaign',
235 'name' => 'description',
236 'type' => CRM_Utils_Type
::T_TEXT
,
237 'title' => ts('Campaign Description'),
238 'description' => ts('Full description of Campaign.'),
241 'where' => 'civicrm_campaign.description',
242 'table_name' => 'civicrm_campaign',
243 'entity' => 'Campaign',
244 'bao' => 'CRM_Campaign_BAO_Campaign',
247 'type' => 'TextArea',
251 'name' => 'start_date',
252 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
253 'title' => ts('Campaign Start Date'),
254 'description' => ts('Date and time that Campaign starts.'),
256 'where' => 'civicrm_campaign.start_date',
257 'headerPattern' => '/^start|(s(tart\s)?date)$/i',
259 'table_name' => 'civicrm_campaign',
260 'entity' => 'Campaign',
261 'bao' => 'CRM_Campaign_BAO_Campaign',
264 'type' => 'Select Date',
268 'name' => 'end_date',
269 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
270 'title' => ts('Campaign End Date'),
271 'description' => ts('Date and time that Campaign ends.'),
273 'where' => 'civicrm_campaign.end_date',
274 'headerPattern' => '/^end|(e(nd\s)?date)$/i',
276 'table_name' => 'civicrm_campaign',
277 'entity' => 'Campaign',
278 'bao' => 'CRM_Campaign_BAO_Campaign',
281 'type' => 'Select Date',
284 'campaign_type_id' => [
285 'name' => 'campaign_type_id',
286 'type' => CRM_Utils_Type
::T_INT
,
287 'title' => ts('Campaign Type'),
288 'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'),
290 'where' => 'civicrm_campaign.campaign_type_id',
293 'table_name' => 'civicrm_campaign',
294 'entity' => 'Campaign',
295 'bao' => 'CRM_Campaign_BAO_Campaign',
300 'pseudoconstant' => [
301 'optionGroupName' => 'campaign_type',
302 'optionEditPath' => 'civicrm/admin/options/campaign_type',
306 'name' => 'status_id',
307 'type' => CRM_Utils_Type
::T_INT
,
308 'title' => ts('Campaign Status'),
309 'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'),
311 'where' => 'civicrm_campaign.status_id',
314 'table_name' => 'civicrm_campaign',
315 'entity' => 'Campaign',
316 'bao' => 'CRM_Campaign_BAO_Campaign',
321 'pseudoconstant' => [
322 'optionGroupName' => 'campaign_status',
323 'optionEditPath' => 'civicrm/admin/options/campaign_status',
326 'external_identifier' => [
327 'name' => 'external_identifier',
328 'type' => CRM_Utils_Type
::T_STRING
,
329 'title' => ts('Campaign External ID'),
330 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
332 'size' => CRM_Utils_Type
::MEDIUM
,
334 'where' => 'civicrm_campaign.external_identifier',
335 'headerPattern' => '/external\s?id/i',
336 'dataPattern' => '/^\d{11,}$/',
338 'table_name' => 'civicrm_campaign',
339 'entity' => 'Campaign',
340 'bao' => 'CRM_Campaign_BAO_Campaign',
347 'name' => 'parent_id',
348 'type' => CRM_Utils_Type
::T_INT
,
349 'title' => ts('Parent Campaign'),
350 'description' => ts('Optional parent id for this Campaign.'),
352 'where' => 'civicrm_campaign.parent_id',
355 'table_name' => 'civicrm_campaign',
356 'entity' => 'Campaign',
357 'bao' => 'CRM_Campaign_BAO_Campaign',
359 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
361 'type' => 'EntityRef',
365 'name' => 'is_active',
366 'type' => CRM_Utils_Type
::T_BOOLEAN
,
367 'title' => ts('Is Campaign Active?'),
368 'description' => ts('Is this Campaign enabled or disabled/cancelled?'),
369 'where' => 'civicrm_campaign.is_active',
371 'table_name' => 'civicrm_campaign',
372 'entity' => 'Campaign',
373 'bao' => 'CRM_Campaign_BAO_Campaign',
376 'type' => 'CheckBox',
380 'name' => 'created_id',
381 'type' => CRM_Utils_Type
::T_INT
,
382 'title' => ts('Campaign Created By'),
383 'description' => ts('FK to civicrm_contact, who created this Campaign.'),
384 'where' => 'civicrm_campaign.created_id',
385 'table_name' => 'civicrm_campaign',
386 'entity' => 'Campaign',
387 'bao' => 'CRM_Campaign_BAO_Campaign',
389 'FKClassName' => 'CRM_Contact_DAO_Contact',
392 'name' => 'created_date',
393 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
394 'title' => ts('Campaign Created Date'),
395 'description' => ts('Date and time that Campaign was created.'),
396 'where' => 'civicrm_campaign.created_date',
397 'table_name' => 'civicrm_campaign',
398 'entity' => 'Campaign',
399 'bao' => 'CRM_Campaign_BAO_Campaign',
402 'type' => 'Select Date',
405 'last_modified_id' => [
406 'name' => 'last_modified_id',
407 'type' => CRM_Utils_Type
::T_INT
,
408 'title' => ts('Campaign Modified By'),
409 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
410 'where' => 'civicrm_campaign.last_modified_id',
411 'table_name' => 'civicrm_campaign',
412 'entity' => 'Campaign',
413 'bao' => 'CRM_Campaign_BAO_Campaign',
415 'FKClassName' => 'CRM_Contact_DAO_Contact',
417 'last_modified_date' => [
418 'name' => 'last_modified_date',
419 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
420 'title' => ts('Campaign Modified Date'),
421 'description' => ts('Date and time that Campaign was edited last time.'),
422 'where' => 'civicrm_campaign.last_modified_date',
423 'table_name' => 'civicrm_campaign',
424 'entity' => 'Campaign',
425 'bao' => 'CRM_Campaign_BAO_Campaign',
429 'name' => 'goal_general',
430 'type' => CRM_Utils_Type
::T_TEXT
,
431 'title' => ts('Campaign Goals'),
432 'description' => ts('General goals for Campaign.'),
433 'where' => 'civicrm_campaign.goal_general',
434 'table_name' => 'civicrm_campaign',
435 'entity' => 'Campaign',
436 'bao' => 'CRM_Campaign_BAO_Campaign',
439 'type' => 'RichTextEditor',
443 'name' => 'goal_revenue',
444 'type' => CRM_Utils_Type
::T_MONEY
,
445 'title' => ts('Goal Revenue'),
446 'description' => ts('The target revenue for this campaign.'),
451 'where' => 'civicrm_campaign.goal_revenue',
452 'table_name' => 'civicrm_campaign',
453 'entity' => 'Campaign',
454 'bao' => 'CRM_Campaign_BAO_Campaign',
461 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
463 return Civi
::$statics[__CLASS__
]['fields'];
467 * Return a mapping from field-name to the corresponding key (as used in fields()).
470 * Array(string $name => string $uniqueName).
472 public static function &fieldKeys() {
473 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
474 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
476 return Civi
::$statics[__CLASS__
]['fieldKeys'];
480 * Returns the names of this table
484 public static function getTableName() {
485 return self
::$_tableName;
489 * Returns if this table needs to be logged
493 public function getLog() {
498 * Returns the list of fields that can be imported
500 * @param bool $prefix
504 public static function &import($prefix = FALSE) {
505 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'campaign', $prefix, []);
510 * Returns the list of fields that can be exported
512 * @param bool $prefix
516 public static function &export($prefix = FALSE) {
517 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'campaign', $prefix, []);
522 * Returns the list of indices
524 * @param bool $localize
528 public static function indices($localize = TRUE) {
530 'UI_campaign_type_id' => [
531 'name' => 'UI_campaign_type_id',
533 0 => 'campaign_type_id',
535 'localizable' => FALSE,
536 'sig' => 'civicrm_campaign::0::campaign_type_id',
538 'UI_campaign_status_id' => [
539 'name' => 'UI_campaign_status_id',
543 'localizable' => FALSE,
544 'sig' => 'civicrm_campaign::0::status_id',
546 'UI_external_identifier' => [
547 'name' => 'UI_external_identifier',
549 0 => 'external_identifier',
551 'localizable' => FALSE,
553 'sig' => 'civicrm_campaign::1::external_identifier',
556 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;