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:bb48d26bc26ec7473c0d22b93275828c)
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;
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
43 * physical tablename for entity being joined to discount, e.g. civicrm_event
46 * (SQL type: varchar(64))
47 * Note that values will be retrieved from the database as a string.
52 * FK to entity table specified in entity_table column.
55 * (SQL type: int unsigned)
56 * Note that values will be retrieved from the database as a string.
61 * FK to civicrm_price_set
64 * (SQL type: int unsigned)
65 * Note that values will be retrieved from the database as a string.
70 * Date when discount starts.
74 * Note that values will be retrieved from the database as a string.
79 * Date when discount ends.
83 * Note that values will be retrieved from the database as a string.
90 public function __construct() {
91 $this->__table
= 'civicrm_discount';
92 parent
::__construct();
96 * Returns localized title of this entity.
99 * Whether to return the plural version of the title.
101 public static function getEntityTitle($plural = FALSE) {
102 return $plural ?
ts('Discounts') : ts('Discount');
106 * Returns foreign keys and entity references.
109 * [CRM_Core_Reference_Interface]
111 public static function getReferenceColumns() {
112 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
113 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
114 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'price_set_id', 'civicrm_price_set', 'id');
115 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Dynamic(self
::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
116 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
118 return Civi
::$statics[__CLASS__
]['links'];
122 * Returns all the column names of this table
126 public static function &fields() {
127 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
128 Civi
::$statics[__CLASS__
]['fields'] = [
131 'type' => CRM_Utils_Type
::T_INT
,
132 'title' => ts('Discount ID'),
133 'description' => ts('primary key'),
135 'where' => 'civicrm_discount.id',
136 'table_name' => 'civicrm_discount',
137 'entity' => 'Discount',
138 'bao' => 'CRM_Core_BAO_Discount',
147 'name' => 'entity_table',
148 'type' => CRM_Utils_Type
::T_STRING
,
149 'title' => ts('Entity Table'),
150 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'),
152 'size' => CRM_Utils_Type
::BIG
,
153 'where' => 'civicrm_discount.entity_table',
154 'table_name' => 'civicrm_discount',
155 'entity' => 'Discount',
156 'bao' => 'CRM_Core_BAO_Discount',
161 'name' => 'entity_id',
162 'type' => CRM_Utils_Type
::T_INT
,
163 'title' => ts('Entity ID'),
164 'description' => ts('FK to entity table specified in entity_table column.'),
166 'where' => 'civicrm_discount.entity_id',
167 'table_name' => 'civicrm_discount',
168 'entity' => 'Discount',
169 'bao' => 'CRM_Core_BAO_Discount',
173 'participant_discount_name' => [
174 'name' => 'price_set_id',
175 'type' => CRM_Utils_Type
::T_INT
,
176 'title' => ts('Price Set ID'),
177 'description' => ts('FK to civicrm_price_set'),
179 'where' => 'civicrm_discount.price_set_id',
181 'table_name' => 'civicrm_discount',
182 'entity' => 'Discount',
183 'bao' => 'CRM_Core_BAO_Discount',
185 'FKClassName' => 'CRM_Price_DAO_PriceSet',
187 'label' => ts("Price Set"),
189 'pseudoconstant' => [
190 'table' => 'civicrm_price_set',
192 'labelColumn' => 'title',
197 'name' => 'start_date',
198 'type' => CRM_Utils_Type
::T_DATE
,
199 'title' => ts('Discount Start Date'),
200 'description' => ts('Date when discount starts.'),
201 'where' => 'civicrm_discount.start_date',
202 'table_name' => 'civicrm_discount',
203 'entity' => 'Discount',
204 'bao' => 'CRM_Core_BAO_Discount',
209 'name' => 'end_date',
210 'type' => CRM_Utils_Type
::T_DATE
,
211 'title' => ts('Discount End Date'),
212 'description' => ts('Date when discount ends.'),
213 'where' => 'civicrm_discount.end_date',
214 'table_name' => 'civicrm_discount',
215 'entity' => 'Discount',
216 'bao' => 'CRM_Core_BAO_Discount',
221 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
223 return Civi
::$statics[__CLASS__
]['fields'];
227 * Return a mapping from field-name to the corresponding key (as used in fields()).
230 * Array(string $name => string $uniqueName).
232 public static function &fieldKeys() {
233 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
234 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
236 return Civi
::$statics[__CLASS__
]['fieldKeys'];
240 * Returns the names of this table
244 public static function getTableName() {
245 return self
::$_tableName;
249 * Returns if this table needs to be logged
253 public function getLog() {
258 * Returns the list of fields that can be imported
260 * @param bool $prefix
264 public static function &import($prefix = FALSE) {
265 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'discount', $prefix, []);
270 * Returns the list of fields that can be exported
272 * @param bool $prefix
276 public static function &export($prefix = FALSE) {
277 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'discount', $prefix, []);
282 * Returns the list of indices
284 * @param bool $localize
288 public static function indices($localize = TRUE) {
291 'name' => 'index_entity',
296 'localizable' => FALSE,
297 'sig' => 'civicrm_discount::0::entity_table::entity_id',
299 'index_entity_option_id' => [
300 'name' => 'index_entity_option_id',
306 'localizable' => FALSE,
307 'sig' => 'civicrm_discount::0::entity_table::entity_id::price_set_id',
310 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;