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:681876b76553a2f0db5a0c0f9d18eda0)
13 * Database access object for the Discount entity.
15 class CRM_Core_DAO_Discount
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '2.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_discount';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = TRUE;
41 * physical tablename for entity being joined to discount, e.g. civicrm_event
48 * FK to entity table specified in entity_table column.
55 * FK to civicrm_price_set
62 * Date when discount starts.
69 * Date when discount ends.
78 public function __construct() {
79 $this->__table
= 'civicrm_discount';
80 parent
::__construct();
84 * Returns localized title of this entity.
87 * Whether to return the plural version of the title.
89 public static function getEntityTitle($plural = FALSE) {
90 return $plural ?
ts('Discounts') : ts('Discount');
94 * Returns foreign keys and entity references.
97 * [CRM_Core_Reference_Interface]
99 public static function getReferenceColumns() {
100 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
101 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
102 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'price_set_id', 'civicrm_price_set', 'id');
103 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
104 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
106 return Civi
::$statics[__CLASS__
]['links'];
110 * Returns all the column names of this table
114 public static function &fields() {
115 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
116 Civi
::$statics[__CLASS__
]['fields'] = [
119 'type' => CRM_Utils_Type
::T_INT
,
120 'title' => ts('Discount ID'),
121 'description' => ts('primary key'),
123 'where' => 'civicrm_discount.id',
124 'table_name' => 'civicrm_discount',
125 'entity' => 'Discount',
126 'bao' => 'CRM_Core_BAO_Discount',
135 'name' => 'entity_table',
136 'type' => CRM_Utils_Type
::T_STRING
,
137 'title' => ts('Entity Table'),
138 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'),
140 'size' => CRM_Utils_Type
::BIG
,
141 'where' => 'civicrm_discount.entity_table',
142 'table_name' => 'civicrm_discount',
143 'entity' => 'Discount',
144 'bao' => 'CRM_Core_BAO_Discount',
149 'name' => 'entity_id',
150 'type' => CRM_Utils_Type
::T_INT
,
151 'title' => ts('Entity ID'),
152 'description' => ts('FK to entity table specified in entity_table column.'),
154 'where' => 'civicrm_discount.entity_id',
155 'table_name' => 'civicrm_discount',
156 'entity' => 'Discount',
157 'bao' => 'CRM_Core_BAO_Discount',
161 'participant_discount_name' => [
162 'name' => 'price_set_id',
163 'type' => CRM_Utils_Type
::T_INT
,
164 'title' => ts('Price Set ID'),
165 'description' => ts('FK to civicrm_price_set'),
167 'where' => 'civicrm_discount.price_set_id',
169 'table_name' => 'civicrm_discount',
170 'entity' => 'Discount',
171 'bao' => 'CRM_Core_BAO_Discount',
173 'FKClassName' => 'CRM_Price_DAO_PriceSet',
175 'label' => ts("Price Set"),
177 'pseudoconstant' => [
178 'table' => 'civicrm_price_set',
180 'labelColumn' => 'title',
185 'name' => 'start_date',
186 'type' => CRM_Utils_Type
::T_DATE
,
187 'title' => ts('Discount Start Date'),
188 'description' => ts('Date when discount starts.'),
189 'where' => 'civicrm_discount.start_date',
190 'table_name' => 'civicrm_discount',
191 'entity' => 'Discount',
192 'bao' => 'CRM_Core_BAO_Discount',
197 'name' => 'end_date',
198 'type' => CRM_Utils_Type
::T_DATE
,
199 'title' => ts('Discount End Date'),
200 'description' => ts('Date when discount ends.'),
201 'where' => 'civicrm_discount.end_date',
202 'table_name' => 'civicrm_discount',
203 'entity' => 'Discount',
204 'bao' => 'CRM_Core_BAO_Discount',
209 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
211 return Civi
::$statics[__CLASS__
]['fields'];
215 * Return a mapping from field-name to the corresponding key (as used in fields()).
218 * Array(string $name => string $uniqueName).
220 public static function &fieldKeys() {
221 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
222 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
224 return Civi
::$statics[__CLASS__
]['fieldKeys'];
228 * Returns the names of this table
232 public static function getTableName() {
233 return self
::$_tableName;
237 * Returns if this table needs to be logged
241 public function getLog() {
246 * Returns the list of fields that can be imported
248 * @param bool $prefix
252 public static function &import($prefix = FALSE) {
253 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'discount', $prefix, []);
258 * Returns the list of fields that can be exported
260 * @param bool $prefix
264 public static function &export($prefix = FALSE) {
265 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'discount', $prefix, []);
270 * Returns the list of indices
272 * @param bool $localize
276 public static function indices($localize = TRUE) {
279 'name' => 'index_entity',
284 'localizable' => FALSE,
285 'sig' => 'civicrm_discount::0::entity_table::entity_id',
287 'index_entity_option_id' => [
288 'name' => 'index_entity_option_id',
294 'localizable' => FALSE,
295 'sig' => 'civicrm_discount::0::entity_table::entity_id::price_set_id',
298 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;