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:598cce8df447dc19cd4c846549be1141)
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]',
51 * Group which this option belongs to.
55 public $option_group_id;
58 * Option string as displayed to users - e.g. the label in an HTML OPTION tag.
65 * 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.
72 * Stores a fixed (non-translated) name for this option value. Lookup functions should use the name as the key for the option value row.
79 * 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.
86 * Bitwise logic can be used to create subsets of options within an option_group for different uses.
93 * Is this the default option for the group?
100 * Controls display sort order.
107 * Optional description.
114 * Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options?
121 * Is this a predefined system object?
128 * Is this option active?
135 * Component that this option value belongs/caters to.
139 public $component_id;
142 * Which Domain is this option value for
151 public $visibility_id;
161 * Hex color value e.g. #ffffff
170 public function __construct() {
171 $this->__table
= 'civicrm_option_value';
172 parent
::__construct();
176 * Returns localized title of this entity.
178 * @param bool $plural
179 * Whether to return the plural version of the title.
181 public static function getEntityTitle($plural = FALSE) {
182 return $plural ?
ts('Option Values') : ts('Option Value');
186 * Returns foreign keys and entity references.
189 * [CRM_Core_Reference_Interface]
191 public static function getReferenceColumns() {
192 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
193 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
194 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
195 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'component_id', 'civicrm_component', 'id');
196 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'domain_id', 'civicrm_domain', 'id');
197 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
199 return Civi
::$statics[__CLASS__
]['links'];
203 * Returns all the column names of this table
207 public static function &fields() {
208 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
209 Civi
::$statics[__CLASS__
]['fields'] = [
212 'type' => CRM_Utils_Type
::T_INT
,
213 'title' => ts('Option Value ID'),
214 'description' => ts('Option ID'),
216 'where' => 'civicrm_option_value.id',
217 'table_name' => 'civicrm_option_value',
218 'entity' => 'OptionValue',
219 'bao' => 'CRM_Core_BAO_OptionValue',
224 'option_group_id' => [
225 'name' => 'option_group_id',
226 'type' => CRM_Utils_Type
::T_INT
,
227 'title' => ts('Option Group ID'),
228 'description' => ts('Group which this option belongs to.'),
230 'where' => 'civicrm_option_value.option_group_id',
231 'table_name' => 'civicrm_option_value',
232 'entity' => 'OptionValue',
233 'bao' => 'CRM_Core_BAO_OptionValue',
235 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
238 'label' => ts("Option Group"),
240 'pseudoconstant' => [
241 'table' => 'civicrm_option_group',
243 'labelColumn' => 'title',
244 'nameColumn' => 'name',
250 'type' => CRM_Utils_Type
::T_STRING
,
251 'title' => ts('Option Label'),
252 'description' => ts('Option string as displayed to users - e.g. the label in an HTML OPTION tag.'),
255 'size' => CRM_Utils_Type
::HUGE
,
256 'where' => 'civicrm_option_value.label',
257 'table_name' => 'civicrm_option_value',
258 'entity' => 'OptionValue',
259 'bao' => 'CRM_Core_BAO_OptionValue',
265 'type' => CRM_Utils_Type
::T_STRING
,
266 'title' => ts('Option Value'),
267 '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.'),
270 'size' => CRM_Utils_Type
::HUGE
,
271 'where' => 'civicrm_option_value.value',
272 'table_name' => 'civicrm_option_value',
273 'entity' => 'OptionValue',
274 'bao' => 'CRM_Core_BAO_OptionValue',
280 'type' => CRM_Utils_Type
::T_STRING
,
281 'title' => ts('Option Name'),
282 '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.'),
284 'size' => CRM_Utils_Type
::HUGE
,
286 'where' => 'civicrm_option_value.name',
288 'table_name' => 'civicrm_option_value',
289 'entity' => 'OptionValue',
290 'bao' => 'CRM_Core_BAO_OptionValue',
295 'name' => 'grouping',
296 'type' => CRM_Utils_Type
::T_STRING
,
297 'title' => ts('Option Grouping Name'),
298 '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.'),
300 'size' => CRM_Utils_Type
::HUGE
,
301 'where' => 'civicrm_option_value.grouping',
302 'table_name' => 'civicrm_option_value',
303 'entity' => 'OptionValue',
304 'bao' => 'CRM_Core_BAO_OptionValue',
310 'type' => CRM_Utils_Type
::T_INT
,
311 'title' => ts('Filter'),
312 'description' => ts('Bitwise logic can be used to create subsets of options within an option_group for different uses.'),
313 'where' => 'civicrm_option_value.filter',
315 'table_name' => 'civicrm_option_value',
316 'entity' => 'OptionValue',
317 'bao' => 'CRM_Core_BAO_OptionValue',
320 'label' => ts("Filter"),
325 'name' => 'is_default',
326 'type' => CRM_Utils_Type
::T_BOOLEAN
,
327 'title' => ts('Option is Default?'),
328 'description' => ts('Is this the default option for the group?'),
329 'where' => 'civicrm_option_value.is_default',
331 'table_name' => 'civicrm_option_value',
332 'entity' => 'OptionValue',
333 'bao' => 'CRM_Core_BAO_OptionValue',
339 'type' => CRM_Utils_Type
::T_INT
,
340 'title' => ts('Order'),
341 'description' => ts('Controls display sort order.'),
343 'where' => 'civicrm_option_value.weight',
344 'table_name' => 'civicrm_option_value',
345 'entity' => 'OptionValue',
346 'bao' => 'CRM_Core_BAO_OptionValue',
351 'name' => 'description',
352 'type' => CRM_Utils_Type
::T_TEXT
,
353 'title' => ts('Option Description'),
354 'description' => ts('Optional description.'),
357 'where' => 'civicrm_option_value.description',
358 'table_name' => 'civicrm_option_value',
359 'entity' => 'OptionValue',
360 'bao' => 'CRM_Core_BAO_OptionValue',
363 'type' => 'TextArea',
368 'name' => 'is_optgroup',
369 'type' => CRM_Utils_Type
::T_BOOLEAN
,
370 'title' => ts('Option is Header?'),
371 '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?'),
372 'where' => 'civicrm_option_value.is_optgroup',
374 'table_name' => 'civicrm_option_value',
375 'entity' => 'OptionValue',
376 'bao' => 'CRM_Core_BAO_OptionValue',
381 'name' => 'is_reserved',
382 'type' => CRM_Utils_Type
::T_BOOLEAN
,
383 'title' => ts('Option Is Reserved?'),
384 'description' => ts('Is this a predefined system object?'),
385 'where' => 'civicrm_option_value.is_reserved',
387 'table_name' => 'civicrm_option_value',
388 'entity' => 'OptionValue',
389 'bao' => 'CRM_Core_BAO_OptionValue',
394 'name' => 'is_active',
395 'type' => CRM_Utils_Type
::T_BOOLEAN
,
396 'title' => ts('Option Is Active'),
397 'description' => ts('Is this option active?'),
398 'where' => 'civicrm_option_value.is_active',
400 'table_name' => 'civicrm_option_value',
401 'entity' => 'OptionValue',
402 'bao' => 'CRM_Core_BAO_OptionValue',
407 'name' => 'component_id',
408 'type' => CRM_Utils_Type
::T_INT
,
409 'title' => ts('Component ID'),
410 'description' => ts('Component that this option value belongs/caters to.'),
411 'where' => 'civicrm_option_value.component_id',
412 'table_name' => 'civicrm_option_value',
413 'entity' => 'OptionValue',
414 'bao' => 'CRM_Core_BAO_OptionValue',
416 'FKClassName' => 'CRM_Core_DAO_Component',
419 'label' => ts("Component"),
421 'pseudoconstant' => [
422 'table' => 'civicrm_component',
424 'labelColumn' => 'name',
429 'name' => 'domain_id',
430 'type' => CRM_Utils_Type
::T_INT
,
431 'title' => ts('Domain ID'),
432 'description' => ts('Which Domain is this option value for'),
433 'where' => 'civicrm_option_value.domain_id',
434 'table_name' => 'civicrm_option_value',
435 'entity' => 'OptionValue',
436 'bao' => 'CRM_Core_BAO_OptionValue',
438 'FKClassName' => 'CRM_Core_DAO_Domain',
440 'label' => ts("Domain"),
442 'pseudoconstant' => [
443 'table' => 'civicrm_domain',
445 'labelColumn' => 'name',
450 'name' => 'visibility_id',
451 'type' => CRM_Utils_Type
::T_INT
,
452 'title' => ts('Option Visibility'),
453 'where' => 'civicrm_option_value.visibility_id',
455 'table_name' => 'civicrm_option_value',
456 'entity' => 'OptionValue',
457 'bao' => 'CRM_Core_BAO_OptionValue',
459 'pseudoconstant' => [
460 'optionGroupName' => 'visibility',
461 'optionEditPath' => 'civicrm/admin/options/visibility',
467 'type' => CRM_Utils_Type
::T_STRING
,
468 'title' => ts('Icon'),
469 'description' => ts('crm-i icon class'),
471 'size' => CRM_Utils_Type
::HUGE
,
472 'where' => 'civicrm_option_value.icon',
474 'table_name' => 'civicrm_option_value',
475 'entity' => 'OptionValue',
476 'bao' => 'CRM_Core_BAO_OptionValue',
482 'type' => CRM_Utils_Type
::T_STRING
,
483 'title' => ts('Color'),
484 'description' => ts('Hex color value e.g. #ffffff'),
486 'size' => CRM_Utils_Type
::HUGE
,
487 'where' => 'civicrm_option_value.color',
489 'table_name' => 'civicrm_option_value',
490 'entity' => 'OptionValue',
491 'bao' => 'CRM_Core_BAO_OptionValue',
496 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
498 return Civi
::$statics[__CLASS__
]['fields'];
502 * Return a mapping from field-name to the corresponding key (as used in fields()).
505 * Array(string $name => string $uniqueName).
507 public static function &fieldKeys() {
508 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
509 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
511 return Civi
::$statics[__CLASS__
]['fieldKeys'];
515 * Returns the names of this table
519 public static function getTableName() {
520 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
524 * Returns if this table needs to be logged
528 public function getLog() {
533 * Returns the list of fields that can be imported
535 * @param bool $prefix
539 public static function &import($prefix = FALSE) {
540 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'option_value', $prefix, []);
545 * Returns the list of fields that can be exported
547 * @param bool $prefix
551 public static function &export($prefix = FALSE) {
552 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'option_value', $prefix, []);
557 * Returns the list of indices
559 * @param bool $localize
563 public static function indices($localize = TRUE) {
565 'index_option_group_id_value' => [
566 'name' => 'index_option_group_id_value',
569 1 => 'option_group_id',
571 'localizable' => FALSE,
572 'sig' => 'civicrm_option_value::0::value(128)::option_group_id',
574 'index_option_group_id_name' => [
575 'name' => 'index_option_group_id_name',
578 1 => 'option_group_id',
580 'localizable' => FALSE,
581 'sig' => 'civicrm_option_value::0::name(128)::option_group_id',
584 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;