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:d6ec5d0b6786067f47617e39acbbbd3c)
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',
134 'name' => 'entity_table',
135 'type' => CRM_Utils_Type
::T_STRING
,
136 'title' => ts('Entity Table'),
137 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'),
139 'size' => CRM_Utils_Type
::BIG
,
140 'where' => 'civicrm_discount.entity_table',
141 'table_name' => 'civicrm_discount',
142 'entity' => 'Discount',
143 'bao' => 'CRM_Core_BAO_Discount',
148 'name' => 'entity_id',
149 'type' => CRM_Utils_Type
::T_INT
,
150 'title' => ts('Entity ID'),
151 'description' => ts('FK to entity table specified in entity_table column.'),
153 'where' => 'civicrm_discount.entity_id',
154 'table_name' => 'civicrm_discount',
155 'entity' => 'Discount',
156 'bao' => 'CRM_Core_BAO_Discount',
160 'participant_discount_name' => [
161 'name' => 'price_set_id',
162 'type' => CRM_Utils_Type
::T_INT
,
163 'title' => ts('Price Set ID'),
164 'description' => ts('FK to civicrm_price_set'),
166 'where' => 'civicrm_discount.price_set_id',
168 'table_name' => 'civicrm_discount',
169 'entity' => 'Discount',
170 'bao' => 'CRM_Core_BAO_Discount',
172 'FKClassName' => 'CRM_Price_DAO_PriceSet',
174 'label' => ts("Price Set"),
176 'pseudoconstant' => [
177 'table' => 'civicrm_price_set',
179 'labelColumn' => 'title',
184 'name' => 'start_date',
185 'type' => CRM_Utils_Type
::T_DATE
,
186 'title' => ts('Discount Start Date'),
187 'description' => ts('Date when discount starts.'),
188 'where' => 'civicrm_discount.start_date',
189 'table_name' => 'civicrm_discount',
190 'entity' => 'Discount',
191 'bao' => 'CRM_Core_BAO_Discount',
196 'name' => 'end_date',
197 'type' => CRM_Utils_Type
::T_DATE
,
198 'title' => ts('Discount End Date'),
199 'description' => ts('Date when discount ends.'),
200 'where' => 'civicrm_discount.end_date',
201 'table_name' => 'civicrm_discount',
202 'entity' => 'Discount',
203 'bao' => 'CRM_Core_BAO_Discount',
208 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
210 return Civi
::$statics[__CLASS__
]['fields'];
214 * Return a mapping from field-name to the corresponding key (as used in fields()).
217 * Array(string $name => string $uniqueName).
219 public static function &fieldKeys() {
220 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
221 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
223 return Civi
::$statics[__CLASS__
]['fieldKeys'];
227 * Returns the names of this table
231 public static function getTableName() {
232 return self
::$_tableName;
236 * Returns if this table needs to be logged
240 public function getLog() {
245 * Returns the list of fields that can be imported
247 * @param bool $prefix
251 public static function &import($prefix = FALSE) {
252 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'discount', $prefix, []);
257 * Returns the list of fields that can be exported
259 * @param bool $prefix
263 public static function &export($prefix = FALSE) {
264 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'discount', $prefix, []);
269 * Returns the list of indices
271 * @param bool $localize
275 public static function indices($localize = TRUE) {
278 'name' => 'index_entity',
283 'localizable' => FALSE,
284 'sig' => 'civicrm_discount::0::entity_table::entity_id',
286 'index_entity_option_id' => [
287 'name' => 'index_entity_option_id',
293 'localizable' => FALSE,
294 'sig' => 'civicrm_discount::0::entity_table::entity_id::price_set_id',
297 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;