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:5fbe08bc556f5b913860a55c6d0cedc4)
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',
131 'name' => 'entity_table',
132 'type' => CRM_Utils_Type
::T_STRING
,
133 'title' => ts('Entity Table'),
134 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'),
136 'size' => CRM_Utils_Type
::BIG
,
137 'where' => 'civicrm_discount.entity_table',
138 'table_name' => 'civicrm_discount',
139 'entity' => 'Discount',
140 'bao' => 'CRM_Core_BAO_Discount',
145 'name' => 'entity_id',
146 'type' => CRM_Utils_Type
::T_INT
,
147 'title' => ts('Entity ID'),
148 'description' => ts('FK to entity table specified in entity_table column.'),
150 'where' => 'civicrm_discount.entity_id',
151 'table_name' => 'civicrm_discount',
152 'entity' => 'Discount',
153 'bao' => 'CRM_Core_BAO_Discount',
157 'participant_discount_name' => [
158 'name' => 'price_set_id',
159 'type' => CRM_Utils_Type
::T_INT
,
160 'title' => ts('Discount Name'),
161 'description' => ts('FK to civicrm_price_set'),
163 'where' => 'civicrm_discount.price_set_id',
165 'table_name' => 'civicrm_discount',
166 'entity' => 'Discount',
167 'bao' => 'CRM_Core_BAO_Discount',
169 'FKClassName' => 'CRM_Price_DAO_PriceSet',
170 'pseudoconstant' => [
171 'table' => 'civicrm_price_set',
173 'labelColumn' => 'title',
178 'name' => 'start_date',
179 'type' => CRM_Utils_Type
::T_DATE
,
180 'title' => ts('Discount Start Date'),
181 'description' => ts('Date when discount starts.'),
182 'where' => 'civicrm_discount.start_date',
183 'table_name' => 'civicrm_discount',
184 'entity' => 'Discount',
185 'bao' => 'CRM_Core_BAO_Discount',
190 'name' => 'end_date',
191 'type' => CRM_Utils_Type
::T_DATE
,
192 'title' => ts('Discount End Date'),
193 'description' => ts('Date when discount ends.'),
194 'where' => 'civicrm_discount.end_date',
195 'table_name' => 'civicrm_discount',
196 'entity' => 'Discount',
197 'bao' => 'CRM_Core_BAO_Discount',
202 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
204 return Civi
::$statics[__CLASS__
]['fields'];
208 * Return a mapping from field-name to the corresponding key (as used in fields()).
211 * Array(string $name => string $uniqueName).
213 public static function &fieldKeys() {
214 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
215 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
217 return Civi
::$statics[__CLASS__
]['fieldKeys'];
221 * Returns the names of this table
225 public static function getTableName() {
226 return self
::$_tableName;
230 * Returns if this table needs to be logged
234 public function getLog() {
239 * Returns the list of fields that can be imported
241 * @param bool $prefix
245 public static function &import($prefix = FALSE) {
246 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'discount', $prefix, []);
251 * Returns the list of fields that can be exported
253 * @param bool $prefix
257 public static function &export($prefix = FALSE) {
258 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'discount', $prefix, []);
263 * Returns the list of indices
265 * @param bool $localize
269 public static function indices($localize = TRUE) {
272 'name' => 'index_entity',
277 'localizable' => FALSE,
278 'sig' => 'civicrm_discount::0::entity_table::entity_id',
280 'index_entity_option_id' => [
281 'name' => 'index_entity_option_id',
287 'localizable' => FALSE,
288 'sig' => 'civicrm_discount::0::entity_table::entity_id::price_set_id',
291 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;