5 * @copyright CiviCRM LLC (c) 2004-2019
7 * Generated from xml/schema/CRM/Core/Discount.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:74c8162f321ac50b965c1416951fe93a)
13 * Database access object for the Discount entity.
15 class CRM_Core_DAO_Discount
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 static $_tableName = 'civicrm_discount';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
39 * physical tablename for entity being joined to discount, e.g. civicrm_event
46 * FK to entity table specified in entity_table column.
53 * FK to civicrm_price_set
60 * Date when discount starts.
67 * Date when discount ends.
76 public function __construct() {
77 $this->__table
= 'civicrm_discount';
78 parent
::__construct();
82 * Returns foreign keys and entity references.
85 * [CRM_Core_Reference_Interface]
87 public static function getReferenceColumns() {
88 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
89 Civi
::$statics[__CLASS__
]['links'] = static ::createReferenceColumns(__CLASS__
);
90 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'price_set_id', 'civicrm_price_set', 'id');
91 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
92 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
94 return Civi
::$statics[__CLASS__
]['links'];
98 * Returns all the column names of this table
102 public static function &fields() {
103 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
104 Civi
::$statics[__CLASS__
]['fields'] = [
107 'type' => CRM_Utils_Type
::T_INT
,
108 'title' => ts('Discount ID'),
109 'description' => ts('primary key'),
111 'table_name' => 'civicrm_discount',
112 'entity' => 'Discount',
113 'bao' => 'CRM_Core_BAO_Discount',
117 'name' => 'entity_table',
118 'type' => CRM_Utils_Type
::T_STRING
,
119 'title' => ts('Entity Table'),
120 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'),
122 'size' => CRM_Utils_Type
::BIG
,
123 'table_name' => 'civicrm_discount',
124 'entity' => 'Discount',
125 'bao' => 'CRM_Core_BAO_Discount',
129 'name' => 'entity_id',
130 'type' => CRM_Utils_Type
::T_INT
,
131 'title' => ts('Entity ID'),
132 'description' => ts('FK to entity table specified in entity_table column.'),
134 'table_name' => 'civicrm_discount',
135 'entity' => 'Discount',
136 'bao' => 'CRM_Core_BAO_Discount',
139 'participant_discount_name' => [
140 'name' => 'price_set_id',
141 'type' => CRM_Utils_Type
::T_INT
,
142 'title' => ts('Discount Name'),
143 'description' => ts('FK to civicrm_price_set'),
146 'where' => 'civicrm_discount.price_set_id',
147 'headerPattern' => '',
149 'table_name' => 'civicrm_discount',
150 'entity' => 'Discount',
151 'bao' => 'CRM_Core_BAO_Discount',
153 'FKClassName' => 'CRM_Price_DAO_PriceSet',
156 'name' => 'start_date',
157 'type' => CRM_Utils_Type
::T_DATE
,
158 'title' => ts('Discount Start Date'),
159 'description' => ts('Date when discount starts.'),
160 'table_name' => 'civicrm_discount',
161 'entity' => 'Discount',
162 'bao' => 'CRM_Core_BAO_Discount',
166 'name' => 'end_date',
167 'type' => CRM_Utils_Type
::T_DATE
,
168 'title' => ts('Discount End Date'),
169 'description' => ts('Date when discount ends.'),
170 'table_name' => 'civicrm_discount',
171 'entity' => 'Discount',
172 'bao' => 'CRM_Core_BAO_Discount',
176 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
178 return Civi
::$statics[__CLASS__
]['fields'];
182 * Return a mapping from field-name to the corresponding key (as used in fields()).
185 * Array(string $name => string $uniqueName).
187 public static function &fieldKeys() {
188 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
189 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
191 return Civi
::$statics[__CLASS__
]['fieldKeys'];
195 * Returns the names of this table
199 public static function getTableName() {
200 return self
::$_tableName;
204 * Returns if this table needs to be logged
208 public function getLog() {
213 * Returns the list of fields that can be imported
215 * @param bool $prefix
219 public static function &import($prefix = FALSE) {
220 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'discount', $prefix, []);
225 * Returns the list of fields that can be exported
227 * @param bool $prefix
231 public static function &export($prefix = FALSE) {
232 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'discount', $prefix, []);
237 * Returns the list of indices
239 * @param bool $localize
243 public static function indices($localize = TRUE) {
246 'name' => 'index_entity',
251 'localizable' => FALSE,
252 'sig' => 'civicrm_discount::0::entity_table::entity_id',
254 'index_entity_option_id' => [
255 'name' => 'index_entity_option_id',
261 'localizable' => FALSE,
262 'sig' => 'civicrm_discount::0::entity_table::entity_id::price_set_id',
265 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;