5 * @copyright CiviCRM LLC (c) 2004-2018
7 * Generated from xml/schema/CRM/Campaign/Campaign.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:c6ffa4ea926f3a52afc754bf44ef8586)
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 static $_tableName = 'civicrm_campaign';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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',
191 'headerPattern' => '',
194 'table_name' => 'civicrm_campaign',
195 'entity' => 'Campaign',
196 'bao' => 'CRM_Campaign_BAO_Campaign',
201 'type' => CRM_Utils_Type
::T_STRING
,
202 'title' => ts('Campaign Name'),
203 'description' => ts('Name of the Campaign.'),
206 'size' => CRM_Utils_Type
::HUGE
,
208 'where' => 'civicrm_campaign.name',
209 'headerPattern' => '',
212 'table_name' => 'civicrm_campaign',
213 'entity' => 'Campaign',
214 'bao' => 'CRM_Campaign_BAO_Campaign',
222 'type' => CRM_Utils_Type
::T_STRING
,
223 'title' => ts('Campaign Title'),
224 'description' => ts('Title of the Campaign.'),
226 'size' => CRM_Utils_Type
::HUGE
,
228 'where' => 'civicrm_campaign.title',
229 'headerPattern' => '',
232 'table_name' => 'civicrm_campaign',
233 'entity' => 'Campaign',
234 'bao' => 'CRM_Campaign_BAO_Campaign',
241 'name' => 'description',
242 'type' => CRM_Utils_Type
::T_TEXT
,
243 'title' => ts('Campaign Description'),
244 'description' => ts('Full description of Campaign.'),
247 'table_name' => 'civicrm_campaign',
248 'entity' => 'Campaign',
249 'bao' => 'CRM_Campaign_BAO_Campaign',
252 'type' => 'TextArea',
256 'name' => 'start_date',
257 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
258 'title' => ts('Campaign Start Date'),
259 'description' => ts('Date and time that Campaign starts.'),
261 'where' => 'civicrm_campaign.start_date',
262 'headerPattern' => '/^start|(s(tart\s)?date)$/i',
265 'table_name' => 'civicrm_campaign',
266 'entity' => 'Campaign',
267 'bao' => 'CRM_Campaign_BAO_Campaign',
270 'type' => 'Select Date',
274 'name' => 'end_date',
275 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
276 'title' => ts('Campaign End Date'),
277 'description' => ts('Date and time that Campaign ends.'),
279 'where' => 'civicrm_campaign.end_date',
280 'headerPattern' => '/^end|(e(nd\s)?date)$/i',
283 'table_name' => 'civicrm_campaign',
284 'entity' => 'Campaign',
285 'bao' => 'CRM_Campaign_BAO_Campaign',
288 'type' => 'Select Date',
291 'campaign_type_id' => [
292 'name' => 'campaign_type_id',
293 'type' => CRM_Utils_Type
::T_INT
,
294 'title' => ts('Campaign Type'),
295 'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'),
297 'where' => 'civicrm_campaign.campaign_type_id',
298 'headerPattern' => '',
302 'table_name' => 'civicrm_campaign',
303 'entity' => 'Campaign',
304 'bao' => 'CRM_Campaign_BAO_Campaign',
309 'pseudoconstant' => [
310 'optionGroupName' => 'campaign_type',
311 'optionEditPath' => 'civicrm/admin/options/campaign_type',
315 'name' => 'status_id',
316 'type' => CRM_Utils_Type
::T_INT
,
317 'title' => ts('Campaign Status'),
318 'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'),
320 'where' => 'civicrm_campaign.status_id',
321 'headerPattern' => '',
325 'table_name' => 'civicrm_campaign',
326 'entity' => 'Campaign',
327 'bao' => 'CRM_Campaign_BAO_Campaign',
332 'pseudoconstant' => [
333 'optionGroupName' => 'campaign_status',
334 'optionEditPath' => 'civicrm/admin/options/campaign_status',
337 'external_identifier' => [
338 'name' => 'external_identifier',
339 'type' => CRM_Utils_Type
::T_STRING
,
340 'title' => ts('Campaign External ID'),
341 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
343 'size' => CRM_Utils_Type
::MEDIUM
,
345 'where' => 'civicrm_campaign.external_identifier',
346 'headerPattern' => '/external\s?id/i',
347 'dataPattern' => '/^\d{11,}$/',
349 'table_name' => 'civicrm_campaign',
350 'entity' => 'Campaign',
351 'bao' => 'CRM_Campaign_BAO_Campaign',
358 'name' => 'parent_id',
359 'type' => CRM_Utils_Type
::T_INT
,
360 'title' => ts('Parent Campaign'),
361 'description' => ts('Optional parent id for this Campaign.'),
363 'where' => 'civicrm_campaign.parent_id',
364 'headerPattern' => '',
368 'table_name' => 'civicrm_campaign',
369 'entity' => 'Campaign',
370 'bao' => 'CRM_Campaign_BAO_Campaign',
372 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
374 'type' => 'EntityRef',
378 'name' => 'is_active',
379 'type' => CRM_Utils_Type
::T_BOOLEAN
,
380 'title' => ts('Is Campaign Active?'),
381 'description' => ts('Is this Campaign enabled or disabled/cancelled?'),
383 'table_name' => 'civicrm_campaign',
384 'entity' => 'Campaign',
385 'bao' => 'CRM_Campaign_BAO_Campaign',
388 'type' => 'CheckBox',
392 'name' => 'created_id',
393 'type' => CRM_Utils_Type
::T_INT
,
394 'title' => ts('Campaign Created By'),
395 'description' => ts('FK to civicrm_contact, who created this Campaign.'),
396 'table_name' => 'civicrm_campaign',
397 'entity' => 'Campaign',
398 'bao' => 'CRM_Campaign_BAO_Campaign',
400 'FKClassName' => 'CRM_Contact_DAO_Contact',
403 'name' => 'created_date',
404 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
405 'title' => ts('Campaign Created Date'),
406 'description' => ts('Date and time that Campaign was created.'),
407 'table_name' => 'civicrm_campaign',
408 'entity' => 'Campaign',
409 'bao' => 'CRM_Campaign_BAO_Campaign',
412 'type' => 'Select Date',
415 'last_modified_id' => [
416 'name' => 'last_modified_id',
417 'type' => CRM_Utils_Type
::T_INT
,
418 'title' => ts('Campaign Modified By'),
419 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
420 'table_name' => 'civicrm_campaign',
421 'entity' => 'Campaign',
422 'bao' => 'CRM_Campaign_BAO_Campaign',
424 'FKClassName' => 'CRM_Contact_DAO_Contact',
426 'last_modified_date' => [
427 'name' => 'last_modified_date',
428 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
429 'title' => ts('Campaign Modified Date'),
430 'description' => ts('Date and time that Campaign was edited last time.'),
431 'table_name' => 'civicrm_campaign',
432 'entity' => 'Campaign',
433 'bao' => 'CRM_Campaign_BAO_Campaign',
437 'name' => 'goal_general',
438 'type' => CRM_Utils_Type
::T_TEXT
,
439 'title' => ts('Campaign Goals'),
440 'description' => ts('General goals for Campaign.'),
441 'table_name' => 'civicrm_campaign',
442 'entity' => 'Campaign',
443 'bao' => 'CRM_Campaign_BAO_Campaign',
446 'type' => 'RichTextEditor',
450 'name' => 'goal_revenue',
451 'type' => CRM_Utils_Type
::T_MONEY
,
452 'title' => ts('Goal Revenue'),
453 'description' => ts('The target revenue for this campaign.'),
458 'table_name' => 'civicrm_campaign',
459 'entity' => 'Campaign',
460 'bao' => 'CRM_Campaign_BAO_Campaign',
467 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
469 return Civi
::$statics[__CLASS__
]['fields'];
473 * Return a mapping from field-name to the corresponding key (as used in fields()).
476 * Array(string $name => string $uniqueName).
478 public static function &fieldKeys() {
479 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
480 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
482 return Civi
::$statics[__CLASS__
]['fieldKeys'];
486 * Returns the names of this table
490 public static function getTableName() {
491 return self
::$_tableName;
495 * Returns if this table needs to be logged
499 public function getLog() {
504 * Returns the list of fields that can be imported
506 * @param bool $prefix
510 public static function &import($prefix = FALSE) {
511 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'campaign', $prefix, []);
516 * Returns the list of fields that can be exported
518 * @param bool $prefix
522 public static function &export($prefix = FALSE) {
523 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'campaign', $prefix, []);
528 * Returns the list of indices
530 * @param bool $localize
534 public static function indices($localize = TRUE) {
536 'UI_campaign_type_id' => [
537 'name' => 'UI_campaign_type_id',
539 0 => 'campaign_type_id',
541 'localizable' => FALSE,
542 'sig' => 'civicrm_campaign::0::campaign_type_id',
544 'UI_campaign_status_id' => [
545 'name' => 'UI_campaign_status_id',
549 'localizable' => FALSE,
550 'sig' => 'civicrm_campaign::0::status_id',
552 'UI_external_identifier' => [
553 'name' => 'UI_external_identifier',
555 0 => 'external_identifier',
557 'localizable' => FALSE,
559 'sig' => 'civicrm_campaign::1::external_identifier',
562 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;