5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/Discount.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:71bcd9deb96abf18da4c7c7769b6a2dd)
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 public static $_tableName = 'civicrm_discount';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
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 'where' => 'civicrm_discount.id',
112 'table_name' => 'civicrm_discount',
113 'entity' => 'Discount',
114 'bao' => 'CRM_Core_BAO_Discount',
118 'name' => 'entity_table',
119 'type' => CRM_Utils_Type
::T_STRING
,
120 'title' => ts('Entity Table'),
121 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'),
123 'size' => CRM_Utils_Type
::BIG
,
124 'where' => 'civicrm_discount.entity_table',
125 'table_name' => 'civicrm_discount',
126 'entity' => 'Discount',
127 'bao' => 'CRM_Core_BAO_Discount',
131 'name' => 'entity_id',
132 'type' => CRM_Utils_Type
::T_INT
,
133 'title' => ts('Entity ID'),
134 'description' => ts('FK to entity table specified in entity_table column.'),
136 'where' => 'civicrm_discount.entity_id',
137 'table_name' => 'civicrm_discount',
138 'entity' => 'Discount',
139 'bao' => 'CRM_Core_BAO_Discount',
142 'participant_discount_name' => [
143 'name' => 'price_set_id',
144 'type' => CRM_Utils_Type
::T_INT
,
145 'title' => ts('Discount Name'),
146 'description' => ts('FK to civicrm_price_set'),
148 'where' => 'civicrm_discount.price_set_id',
150 'table_name' => 'civicrm_discount',
151 'entity' => 'Discount',
152 'bao' => 'CRM_Core_BAO_Discount',
154 'FKClassName' => 'CRM_Price_DAO_PriceSet',
157 'name' => 'start_date',
158 'type' => CRM_Utils_Type
::T_DATE
,
159 'title' => ts('Discount Start Date'),
160 'description' => ts('Date when discount starts.'),
161 'where' => 'civicrm_discount.start_date',
162 'table_name' => 'civicrm_discount',
163 'entity' => 'Discount',
164 'bao' => 'CRM_Core_BAO_Discount',
168 'name' => 'end_date',
169 'type' => CRM_Utils_Type
::T_DATE
,
170 'title' => ts('Discount End Date'),
171 'description' => ts('Date when discount ends.'),
172 'where' => 'civicrm_discount.end_date',
173 'table_name' => 'civicrm_discount',
174 'entity' => 'Discount',
175 'bao' => 'CRM_Core_BAO_Discount',
179 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
181 return Civi
::$statics[__CLASS__
]['fields'];
185 * Return a mapping from field-name to the corresponding key (as used in fields()).
188 * Array(string $name => string $uniqueName).
190 public static function &fieldKeys() {
191 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
192 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
194 return Civi
::$statics[__CLASS__
]['fieldKeys'];
198 * Returns the names of this table
202 public static function getTableName() {
203 return self
::$_tableName;
207 * Returns if this table needs to be logged
211 public function getLog() {
216 * Returns the list of fields that can be imported
218 * @param bool $prefix
222 public static function &import($prefix = FALSE) {
223 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'discount', $prefix, []);
228 * Returns the list of fields that can be exported
230 * @param bool $prefix
234 public static function &export($prefix = FALSE) {
235 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'discount', $prefix, []);
240 * Returns the list of indices
242 * @param bool $localize
246 public static function indices($localize = TRUE) {
249 'name' => 'index_entity',
254 'localizable' => FALSE,
255 'sig' => 'civicrm_discount::0::entity_table::entity_id',
257 'index_entity_option_id' => [
258 'name' => 'index_entity_option_id',
264 'localizable' => FALSE,
265 'sig' => 'civicrm_discount::0::entity_table::entity_id::price_set_id',
268 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;