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:b240911ddcf71cc294fe02614887711c)
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 localized title of this entity.
84 public static function getEntityTitle() {
85 return ts('Discounts');
89 * Returns foreign keys and entity references.
92 * [CRM_Core_Reference_Interface]
94 public static function getReferenceColumns() {
95 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
96 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
97 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'price_set_id', 'civicrm_price_set', 'id');
98 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
99 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
101 return Civi
::$statics[__CLASS__
]['links'];
105 * Returns all the column names of this table
109 public static function &fields() {
110 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
111 Civi
::$statics[__CLASS__
]['fields'] = [
114 'type' => CRM_Utils_Type
::T_INT
,
115 'title' => ts('Discount ID'),
116 'description' => ts('primary key'),
118 'where' => 'civicrm_discount.id',
119 'table_name' => 'civicrm_discount',
120 'entity' => 'Discount',
121 'bao' => 'CRM_Core_BAO_Discount',
126 'name' => 'entity_table',
127 'type' => CRM_Utils_Type
::T_STRING
,
128 'title' => ts('Entity Table'),
129 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'),
131 'size' => CRM_Utils_Type
::BIG
,
132 'where' => 'civicrm_discount.entity_table',
133 'table_name' => 'civicrm_discount',
134 'entity' => 'Discount',
135 'bao' => 'CRM_Core_BAO_Discount',
140 'name' => 'entity_id',
141 'type' => CRM_Utils_Type
::T_INT
,
142 'title' => ts('Entity ID'),
143 'description' => ts('FK to entity table specified in entity_table column.'),
145 'where' => 'civicrm_discount.entity_id',
146 'table_name' => 'civicrm_discount',
147 'entity' => 'Discount',
148 'bao' => 'CRM_Core_BAO_Discount',
152 'participant_discount_name' => [
153 'name' => 'price_set_id',
154 'type' => CRM_Utils_Type
::T_INT
,
155 'title' => ts('Discount Name'),
156 'description' => ts('FK to civicrm_price_set'),
158 'where' => 'civicrm_discount.price_set_id',
160 'table_name' => 'civicrm_discount',
161 'entity' => 'Discount',
162 'bao' => 'CRM_Core_BAO_Discount',
164 'FKClassName' => 'CRM_Price_DAO_PriceSet',
165 'pseudoconstant' => [
166 'table' => 'civicrm_price_set',
168 'labelColumn' => 'title',
173 'name' => 'start_date',
174 'type' => CRM_Utils_Type
::T_DATE
,
175 'title' => ts('Discount Start Date'),
176 'description' => ts('Date when discount starts.'),
177 'where' => 'civicrm_discount.start_date',
178 'table_name' => 'civicrm_discount',
179 'entity' => 'Discount',
180 'bao' => 'CRM_Core_BAO_Discount',
185 'name' => 'end_date',
186 'type' => CRM_Utils_Type
::T_DATE
,
187 'title' => ts('Discount End Date'),
188 'description' => ts('Date when discount ends.'),
189 'where' => 'civicrm_discount.end_date',
190 'table_name' => 'civicrm_discount',
191 'entity' => 'Discount',
192 'bao' => 'CRM_Core_BAO_Discount',
197 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
199 return Civi
::$statics[__CLASS__
]['fields'];
203 * Return a mapping from field-name to the corresponding key (as used in fields()).
206 * Array(string $name => string $uniqueName).
208 public static function &fieldKeys() {
209 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
210 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
212 return Civi
::$statics[__CLASS__
]['fieldKeys'];
216 * Returns the names of this table
220 public static function getTableName() {
221 return self
::$_tableName;
225 * Returns if this table needs to be logged
229 public function getLog() {
234 * Returns the list of fields that can be imported
236 * @param bool $prefix
240 public static function &import($prefix = FALSE) {
241 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'discount', $prefix, []);
246 * Returns the list of fields that can be exported
248 * @param bool $prefix
252 public static function &export($prefix = FALSE) {
253 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'discount', $prefix, []);
258 * Returns the list of indices
260 * @param bool $localize
264 public static function indices($localize = TRUE) {
267 'name' => 'index_entity',
272 'localizable' => FALSE,
273 'sig' => 'civicrm_discount::0::entity_table::entity_id',
275 'index_entity_option_id' => [
276 'name' => 'index_entity_option_id',
282 'localizable' => FALSE,
283 'sig' => 'civicrm_discount::0::entity_table::entity_id::price_set_id',
286 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;