5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/OptionValue.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:36f4f8d1b40d94da47ebebaf3cf77f09)
13 * Database access object for the OptionValue entity.
15 class CRM_Core_DAO_OptionValue
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.5';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_option_value';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = TRUE;
34 * Paths for accessing this entity in the UI.
38 protected static $_paths = [
39 'update' => 'civicrm/admin/options/[option_group_id:name]?reset=1&action=update&id=[id]',
40 'delete' => 'civicrm/admin/options/[option_group_id:name]?reset=1&action=delete&id=[id]',
46 * @var int|string|null
47 * (SQL type: int unsigned)
48 * Note that values will be retrieved from the database as a string.
53 * Group which this option belongs to.
56 * (SQL type: int unsigned)
57 * Note that values will be retrieved from the database as a string.
59 public $option_group_id;
62 * Option string as displayed to users - e.g. the label in an HTML OPTION tag.
65 * (SQL type: varchar(512))
66 * Note that values will be retrieved from the database as a string.
71 * The actual value stored (as a foreign key) in the data record. Functions which need lookup option_value.title should use civicrm_option_value.option_group_id plus civicrm_option_value.value as the key.
74 * (SQL type: varchar(512))
75 * Note that values will be retrieved from the database as a string.
80 * Stores a fixed (non-translated) name for this option value. Lookup functions should use the name as the key for the option value row.
83 * (SQL type: varchar(255))
84 * Note that values will be retrieved from the database as a string.
89 * Use to sort and/or set display properties for sub-set(s) of options within an option group. EXAMPLE: Use for college_interest field, to differentiate partners from non-partners.
92 * (SQL type: varchar(255))
93 * Note that values will be retrieved from the database as a string.
98 * Bitwise logic can be used to create subsets of options within an option_group for different uses.
100 * @var int|string|null
101 * (SQL type: int unsigned)
102 * Note that values will be retrieved from the database as a string.
107 * Is this the default option for the group?
109 * @var bool|string|null
110 * (SQL type: tinyint)
111 * Note that values will be retrieved from the database as a string.
116 * Controls display sort order.
119 * (SQL type: int unsigned)
120 * Note that values will be retrieved from the database as a string.
125 * Optional description.
129 * Note that values will be retrieved from the database as a string.
134 * Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options?
136 * @var bool|string|null
137 * (SQL type: tinyint)
138 * Note that values will be retrieved from the database as a string.
143 * Is this a predefined system object?
145 * @var bool|string|null
146 * (SQL type: tinyint)
147 * Note that values will be retrieved from the database as a string.
152 * Is this option active?
154 * @var bool|string|null
155 * (SQL type: tinyint)
156 * Note that values will be retrieved from the database as a string.
161 * Component that this option value belongs/caters to.
163 * @var int|string|null
164 * (SQL type: int unsigned)
165 * Note that values will be retrieved from the database as a string.
167 public $component_id;
170 * Which Domain is this option value for
172 * @var int|string|null
173 * (SQL type: int unsigned)
174 * Note that values will be retrieved from the database as a string.
179 * @var int|string|null
180 * (SQL type: int unsigned)
181 * Note that values will be retrieved from the database as a string.
183 public $visibility_id;
189 * (SQL type: varchar(255))
190 * Note that values will be retrieved from the database as a string.
195 * Hex color value e.g. #ffffff
198 * (SQL type: varchar(255))
199 * Note that values will be retrieved from the database as a string.
206 public function __construct() {
207 $this->__table
= 'civicrm_option_value';
208 parent
::__construct();
212 * Returns localized title of this entity.
214 * @param bool $plural
215 * Whether to return the plural version of the title.
217 public static function getEntityTitle($plural = FALSE) {
218 return $plural ?
ts('Option Values') : ts('Option Value');
222 * Returns foreign keys and entity references.
225 * [CRM_Core_Reference_Interface]
227 public static function getReferenceColumns() {
228 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
229 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
230 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
231 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'component_id', 'civicrm_component', 'id');
232 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'domain_id', 'civicrm_domain', 'id');
233 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
235 return Civi
::$statics[__CLASS__
]['links'];
239 * Returns all the column names of this table
243 public static function &fields() {
244 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
245 Civi
::$statics[__CLASS__
]['fields'] = [
248 'type' => CRM_Utils_Type
::T_INT
,
249 'title' => ts('Option Value ID'),
250 'description' => ts('Option ID'),
252 'where' => 'civicrm_option_value.id',
253 'table_name' => 'civicrm_option_value',
254 'entity' => 'OptionValue',
255 'bao' => 'CRM_Core_BAO_OptionValue',
260 'option_group_id' => [
261 'name' => 'option_group_id',
262 'type' => CRM_Utils_Type
::T_INT
,
263 'title' => ts('Option Group ID'),
264 'description' => ts('Group which this option belongs to.'),
266 'where' => 'civicrm_option_value.option_group_id',
267 'table_name' => 'civicrm_option_value',
268 'entity' => 'OptionValue',
269 'bao' => 'CRM_Core_BAO_OptionValue',
271 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
274 'label' => ts("Option Group"),
276 'pseudoconstant' => [
277 'table' => 'civicrm_option_group',
279 'labelColumn' => 'title',
280 'nameColumn' => 'name',
286 'type' => CRM_Utils_Type
::T_STRING
,
287 'title' => ts('Option Label'),
288 'description' => ts('Option string as displayed to users - e.g. the label in an HTML OPTION tag.'),
291 'size' => CRM_Utils_Type
::HUGE
,
292 'where' => 'civicrm_option_value.label',
293 'table_name' => 'civicrm_option_value',
294 'entity' => 'OptionValue',
295 'bao' => 'CRM_Core_BAO_OptionValue',
301 'type' => CRM_Utils_Type
::T_STRING
,
302 'title' => ts('Option Value'),
303 'description' => ts('The actual value stored (as a foreign key) in the data record. Functions which need lookup option_value.title should use civicrm_option_value.option_group_id plus civicrm_option_value.value as the key.'),
306 'size' => CRM_Utils_Type
::HUGE
,
307 'where' => 'civicrm_option_value.value',
308 'table_name' => 'civicrm_option_value',
309 'entity' => 'OptionValue',
310 'bao' => 'CRM_Core_BAO_OptionValue',
316 'type' => CRM_Utils_Type
::T_STRING
,
317 'title' => ts('Option Name'),
318 'description' => ts('Stores a fixed (non-translated) name for this option value. Lookup functions should use the name as the key for the option value row.'),
320 'size' => CRM_Utils_Type
::HUGE
,
322 'where' => 'civicrm_option_value.name',
324 'table_name' => 'civicrm_option_value',
325 'entity' => 'OptionValue',
326 'bao' => 'CRM_Core_BAO_OptionValue',
331 'name' => 'grouping',
332 'type' => CRM_Utils_Type
::T_STRING
,
333 'title' => ts('Option Grouping Name'),
334 'description' => ts('Use to sort and/or set display properties for sub-set(s) of options within an option group. EXAMPLE: Use for college_interest field, to differentiate partners from non-partners.'),
336 'size' => CRM_Utils_Type
::HUGE
,
337 'where' => 'civicrm_option_value.grouping',
338 'table_name' => 'civicrm_option_value',
339 'entity' => 'OptionValue',
340 'bao' => 'CRM_Core_BAO_OptionValue',
346 'type' => CRM_Utils_Type
::T_INT
,
347 'title' => ts('Filter'),
348 'description' => ts('Bitwise logic can be used to create subsets of options within an option_group for different uses.'),
349 'where' => 'civicrm_option_value.filter',
351 'table_name' => 'civicrm_option_value',
352 'entity' => 'OptionValue',
353 'bao' => 'CRM_Core_BAO_OptionValue',
356 'label' => ts("Filter"),
361 'name' => 'is_default',
362 'type' => CRM_Utils_Type
::T_BOOLEAN
,
363 'title' => ts('Option is Default?'),
364 'description' => ts('Is this the default option for the group?'),
365 'where' => 'civicrm_option_value.is_default',
367 'table_name' => 'civicrm_option_value',
368 'entity' => 'OptionValue',
369 'bao' => 'CRM_Core_BAO_OptionValue',
375 'type' => CRM_Utils_Type
::T_INT
,
376 'title' => ts('Order'),
377 'description' => ts('Controls display sort order.'),
379 'where' => 'civicrm_option_value.weight',
380 'table_name' => 'civicrm_option_value',
381 'entity' => 'OptionValue',
382 'bao' => 'CRM_Core_BAO_OptionValue',
387 'name' => 'description',
388 'type' => CRM_Utils_Type
::T_TEXT
,
389 'title' => ts('Option Description'),
390 'description' => ts('Optional description.'),
393 'where' => 'civicrm_option_value.description',
394 'table_name' => 'civicrm_option_value',
395 'entity' => 'OptionValue',
396 'bao' => 'CRM_Core_BAO_OptionValue',
399 'type' => 'TextArea',
404 'name' => 'is_optgroup',
405 'type' => CRM_Utils_Type
::T_BOOLEAN
,
406 'title' => ts('Option is Header?'),
407 'description' => ts('Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options?'),
408 'where' => 'civicrm_option_value.is_optgroup',
410 'table_name' => 'civicrm_option_value',
411 'entity' => 'OptionValue',
412 'bao' => 'CRM_Core_BAO_OptionValue',
417 'name' => 'is_reserved',
418 'type' => CRM_Utils_Type
::T_BOOLEAN
,
419 'title' => ts('Option Is Reserved?'),
420 'description' => ts('Is this a predefined system object?'),
421 'where' => 'civicrm_option_value.is_reserved',
423 'table_name' => 'civicrm_option_value',
424 'entity' => 'OptionValue',
425 'bao' => 'CRM_Core_BAO_OptionValue',
430 'name' => 'is_active',
431 'type' => CRM_Utils_Type
::T_BOOLEAN
,
432 'title' => ts('Option Is Active'),
433 'description' => ts('Is this option active?'),
434 'where' => 'civicrm_option_value.is_active',
436 'table_name' => 'civicrm_option_value',
437 'entity' => 'OptionValue',
438 'bao' => 'CRM_Core_BAO_OptionValue',
443 'name' => 'component_id',
444 'type' => CRM_Utils_Type
::T_INT
,
445 'title' => ts('Component ID'),
446 'description' => ts('Component that this option value belongs/caters to.'),
447 'where' => 'civicrm_option_value.component_id',
448 'table_name' => 'civicrm_option_value',
449 'entity' => 'OptionValue',
450 'bao' => 'CRM_Core_BAO_OptionValue',
452 'FKClassName' => 'CRM_Core_DAO_Component',
455 'label' => ts("Component"),
457 'pseudoconstant' => [
458 'table' => 'civicrm_component',
460 'labelColumn' => 'name',
465 'name' => 'domain_id',
466 'type' => CRM_Utils_Type
::T_INT
,
467 'title' => ts('Domain ID'),
468 'description' => ts('Which Domain is this option value for'),
469 'where' => 'civicrm_option_value.domain_id',
470 'table_name' => 'civicrm_option_value',
471 'entity' => 'OptionValue',
472 'bao' => 'CRM_Core_BAO_OptionValue',
474 'FKClassName' => 'CRM_Core_DAO_Domain',
476 'label' => ts("Domain"),
478 'pseudoconstant' => [
479 'table' => 'civicrm_domain',
481 'labelColumn' => 'name',
486 'name' => 'visibility_id',
487 'type' => CRM_Utils_Type
::T_INT
,
488 'title' => ts('Option Visibility'),
489 'where' => 'civicrm_option_value.visibility_id',
491 'table_name' => 'civicrm_option_value',
492 'entity' => 'OptionValue',
493 'bao' => 'CRM_Core_BAO_OptionValue',
495 'pseudoconstant' => [
496 'optionGroupName' => 'visibility',
497 'optionEditPath' => 'civicrm/admin/options/visibility',
503 'type' => CRM_Utils_Type
::T_STRING
,
504 'title' => ts('Icon'),
505 'description' => ts('crm-i icon class'),
507 'size' => CRM_Utils_Type
::HUGE
,
508 'where' => 'civicrm_option_value.icon',
510 'table_name' => 'civicrm_option_value',
511 'entity' => 'OptionValue',
512 'bao' => 'CRM_Core_BAO_OptionValue',
518 'type' => CRM_Utils_Type
::T_STRING
,
519 'title' => ts('Color'),
520 'description' => ts('Hex color value e.g. #ffffff'),
522 'size' => CRM_Utils_Type
::HUGE
,
523 'where' => 'civicrm_option_value.color',
525 'table_name' => 'civicrm_option_value',
526 'entity' => 'OptionValue',
527 'bao' => 'CRM_Core_BAO_OptionValue',
532 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
534 return Civi
::$statics[__CLASS__
]['fields'];
538 * Return a mapping from field-name to the corresponding key (as used in fields()).
541 * Array(string $name => string $uniqueName).
543 public static function &fieldKeys() {
544 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
545 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
547 return Civi
::$statics[__CLASS__
]['fieldKeys'];
551 * Returns the names of this table
555 public static function getTableName() {
556 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
560 * Returns if this table needs to be logged
564 public function getLog() {
569 * Returns the list of fields that can be imported
571 * @param bool $prefix
575 public static function &import($prefix = FALSE) {
576 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'option_value', $prefix, []);
581 * Returns the list of fields that can be exported
583 * @param bool $prefix
587 public static function &export($prefix = FALSE) {
588 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'option_value', $prefix, []);
593 * Returns the list of indices
595 * @param bool $localize
599 public static function indices($localize = TRUE) {
601 'index_option_group_id_value' => [
602 'name' => 'index_option_group_id_value',
605 1 => 'option_group_id',
607 'localizable' => FALSE,
608 'sig' => 'civicrm_option_value::0::value(128)::option_group_id',
610 'index_option_group_id_name' => [
611 'name' => 'index_option_group_id_name',
614 1 => 'option_group_id',
616 'localizable' => FALSE,
617 'sig' => 'civicrm_option_value::0::name(128)::option_group_id',
620 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;