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:171565168517add49222893871a84e43)
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;
41 * Group which this option belongs to.
45 public $option_group_id;
48 * Option string as displayed to users - e.g. the label in an HTML OPTION tag.
55 * 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.
62 * Stores a fixed (non-translated) name for this option value. Lookup functions should use the name as the key for the option value row.
69 * 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.
76 * Bitwise logic can be used to create subsets of options within an option_group for different uses.
83 * Is this the default option for the group?
90 * Controls display sort order.
97 * Optional description.
104 * Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options?
111 * Is this a predefined system object?
118 * Is this option active?
125 * Component that this option value belongs/caters to.
129 public $component_id;
132 * Which Domain is this option value for
141 public $visibility_id;
151 * Hex color value e.g. #ffffff
160 public function __construct() {
161 $this->__table
= 'civicrm_option_value';
162 parent
::__construct();
166 * Returns localized title of this entity.
168 * @param bool $plural
169 * Whether to return the plural version of the title.
171 public static function getEntityTitle($plural = FALSE) {
172 return $plural ?
ts('Option Values') : ts('Option Value');
176 * Returns foreign keys and entity references.
179 * [CRM_Core_Reference_Interface]
181 public static function getReferenceColumns() {
182 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
183 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
184 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
185 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'component_id', 'civicrm_component', 'id');
186 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'domain_id', 'civicrm_domain', 'id');
187 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
189 return Civi
::$statics[__CLASS__
]['links'];
193 * Returns all the column names of this table
197 public static function &fields() {
198 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
199 Civi
::$statics[__CLASS__
]['fields'] = [
202 'type' => CRM_Utils_Type
::T_INT
,
203 'title' => ts('Option Value ID'),
204 'description' => ts('Option ID'),
206 'where' => 'civicrm_option_value.id',
207 'table_name' => 'civicrm_option_value',
208 'entity' => 'OptionValue',
209 'bao' => 'CRM_Core_BAO_OptionValue',
214 'option_group_id' => [
215 'name' => 'option_group_id',
216 'type' => CRM_Utils_Type
::T_INT
,
217 'title' => ts('Option Group ID'),
218 'description' => ts('Group which this option belongs to.'),
220 'where' => 'civicrm_option_value.option_group_id',
221 'table_name' => 'civicrm_option_value',
222 'entity' => 'OptionValue',
223 'bao' => 'CRM_Core_BAO_OptionValue',
225 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
228 'label' => ts("Option Group"),
230 'pseudoconstant' => [
231 'table' => 'civicrm_option_group',
233 'labelColumn' => 'title',
234 'nameColumn' => 'name',
240 'type' => CRM_Utils_Type
::T_STRING
,
241 'title' => ts('Option Label'),
242 'description' => ts('Option string as displayed to users - e.g. the label in an HTML OPTION tag.'),
245 'size' => CRM_Utils_Type
::HUGE
,
246 'where' => 'civicrm_option_value.label',
247 'table_name' => 'civicrm_option_value',
248 'entity' => 'OptionValue',
249 'bao' => 'CRM_Core_BAO_OptionValue',
255 'type' => CRM_Utils_Type
::T_STRING
,
256 'title' => ts('Option Value'),
257 '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.'),
260 'size' => CRM_Utils_Type
::HUGE
,
261 'where' => 'civicrm_option_value.value',
262 'table_name' => 'civicrm_option_value',
263 'entity' => 'OptionValue',
264 'bao' => 'CRM_Core_BAO_OptionValue',
270 'type' => CRM_Utils_Type
::T_STRING
,
271 'title' => ts('Option Name'),
272 '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.'),
274 'size' => CRM_Utils_Type
::HUGE
,
276 'where' => 'civicrm_option_value.name',
278 'table_name' => 'civicrm_option_value',
279 'entity' => 'OptionValue',
280 'bao' => 'CRM_Core_BAO_OptionValue',
285 'name' => 'grouping',
286 'type' => CRM_Utils_Type
::T_STRING
,
287 'title' => ts('Option Grouping Name'),
288 '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.'),
290 'size' => CRM_Utils_Type
::HUGE
,
291 'where' => 'civicrm_option_value.grouping',
292 'table_name' => 'civicrm_option_value',
293 'entity' => 'OptionValue',
294 'bao' => 'CRM_Core_BAO_OptionValue',
300 'type' => CRM_Utils_Type
::T_INT
,
301 'title' => ts('Filter'),
302 'description' => ts('Bitwise logic can be used to create subsets of options within an option_group for different uses.'),
303 'where' => 'civicrm_option_value.filter',
305 'table_name' => 'civicrm_option_value',
306 'entity' => 'OptionValue',
307 'bao' => 'CRM_Core_BAO_OptionValue',
310 'label' => ts("Filter"),
315 'name' => 'is_default',
316 'type' => CRM_Utils_Type
::T_BOOLEAN
,
317 'title' => ts('Option is Default?'),
318 'description' => ts('Is this the default option for the group?'),
319 'where' => 'civicrm_option_value.is_default',
321 'table_name' => 'civicrm_option_value',
322 'entity' => 'OptionValue',
323 'bao' => 'CRM_Core_BAO_OptionValue',
329 'type' => CRM_Utils_Type
::T_INT
,
330 'title' => ts('Order'),
331 'description' => ts('Controls display sort order.'),
333 'where' => 'civicrm_option_value.weight',
334 'table_name' => 'civicrm_option_value',
335 'entity' => 'OptionValue',
336 'bao' => 'CRM_Core_BAO_OptionValue',
341 'name' => 'description',
342 'type' => CRM_Utils_Type
::T_TEXT
,
343 'title' => ts('Option Description'),
344 'description' => ts('Optional description.'),
347 'where' => 'civicrm_option_value.description',
348 'table_name' => 'civicrm_option_value',
349 'entity' => 'OptionValue',
350 'bao' => 'CRM_Core_BAO_OptionValue',
353 'type' => 'TextArea',
358 'name' => 'is_optgroup',
359 'type' => CRM_Utils_Type
::T_BOOLEAN
,
360 'title' => ts('Option is Header?'),
361 '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?'),
362 'where' => 'civicrm_option_value.is_optgroup',
364 'table_name' => 'civicrm_option_value',
365 'entity' => 'OptionValue',
366 'bao' => 'CRM_Core_BAO_OptionValue',
371 'name' => 'is_reserved',
372 'type' => CRM_Utils_Type
::T_BOOLEAN
,
373 'title' => ts('Option Is Reserved?'),
374 'description' => ts('Is this a predefined system object?'),
375 'where' => 'civicrm_option_value.is_reserved',
377 'table_name' => 'civicrm_option_value',
378 'entity' => 'OptionValue',
379 'bao' => 'CRM_Core_BAO_OptionValue',
384 'name' => 'is_active',
385 'type' => CRM_Utils_Type
::T_BOOLEAN
,
386 'title' => ts('Option Is Active'),
387 'description' => ts('Is this option active?'),
388 'where' => 'civicrm_option_value.is_active',
390 'table_name' => 'civicrm_option_value',
391 'entity' => 'OptionValue',
392 'bao' => 'CRM_Core_BAO_OptionValue',
397 'name' => 'component_id',
398 'type' => CRM_Utils_Type
::T_INT
,
399 'title' => ts('Component ID'),
400 'description' => ts('Component that this option value belongs/caters to.'),
401 'where' => 'civicrm_option_value.component_id',
402 'table_name' => 'civicrm_option_value',
403 'entity' => 'OptionValue',
404 'bao' => 'CRM_Core_BAO_OptionValue',
406 'FKClassName' => 'CRM_Core_DAO_Component',
409 'label' => ts("Component"),
411 'pseudoconstant' => [
412 'table' => 'civicrm_component',
414 'labelColumn' => 'name',
419 'name' => 'domain_id',
420 'type' => CRM_Utils_Type
::T_INT
,
421 'title' => ts('Domain ID'),
422 'description' => ts('Which Domain is this option value for'),
423 'where' => 'civicrm_option_value.domain_id',
424 'table_name' => 'civicrm_option_value',
425 'entity' => 'OptionValue',
426 'bao' => 'CRM_Core_BAO_OptionValue',
428 'FKClassName' => 'CRM_Core_DAO_Domain',
430 'label' => ts("Domain"),
432 'pseudoconstant' => [
433 'table' => 'civicrm_domain',
435 'labelColumn' => 'name',
440 'name' => 'visibility_id',
441 'type' => CRM_Utils_Type
::T_INT
,
442 'title' => ts('Option Visibility'),
443 'where' => 'civicrm_option_value.visibility_id',
445 'table_name' => 'civicrm_option_value',
446 'entity' => 'OptionValue',
447 'bao' => 'CRM_Core_BAO_OptionValue',
449 'pseudoconstant' => [
450 'optionGroupName' => 'visibility',
451 'optionEditPath' => 'civicrm/admin/options/visibility',
457 'type' => CRM_Utils_Type
::T_STRING
,
458 'title' => ts('Icon'),
459 'description' => ts('crm-i icon class'),
461 'size' => CRM_Utils_Type
::HUGE
,
462 'where' => 'civicrm_option_value.icon',
464 'table_name' => 'civicrm_option_value',
465 'entity' => 'OptionValue',
466 'bao' => 'CRM_Core_BAO_OptionValue',
472 'type' => CRM_Utils_Type
::T_STRING
,
473 'title' => ts('Color'),
474 'description' => ts('Hex color value e.g. #ffffff'),
476 'size' => CRM_Utils_Type
::HUGE
,
477 'where' => 'civicrm_option_value.color',
479 'table_name' => 'civicrm_option_value',
480 'entity' => 'OptionValue',
481 'bao' => 'CRM_Core_BAO_OptionValue',
486 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
488 return Civi
::$statics[__CLASS__
]['fields'];
492 * Return a mapping from field-name to the corresponding key (as used in fields()).
495 * Array(string $name => string $uniqueName).
497 public static function &fieldKeys() {
498 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
499 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
501 return Civi
::$statics[__CLASS__
]['fieldKeys'];
505 * Returns the names of this table
509 public static function getTableName() {
510 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
514 * Returns if this table needs to be logged
518 public function getLog() {
523 * Returns the list of fields that can be imported
525 * @param bool $prefix
529 public static function &import($prefix = FALSE) {
530 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'option_value', $prefix, []);
535 * Returns the list of fields that can be exported
537 * @param bool $prefix
541 public static function &export($prefix = FALSE) {
542 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'option_value', $prefix, []);
547 * Returns the list of indices
549 * @param bool $localize
553 public static function indices($localize = TRUE) {
555 'index_option_group_id_value' => [
556 'name' => 'index_option_group_id_value',
559 1 => 'option_group_id',
561 'localizable' => FALSE,
562 'sig' => 'civicrm_option_value::0::value(128)::option_group_id',
564 'index_option_group_id_name' => [
565 'name' => 'index_option_group_id_name',
568 1 => 'option_group_id',
570 'localizable' => FALSE,
571 'sig' => 'civicrm_option_value::0::name(128)::option_group_id',
574 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;