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:f47024ac081427ddadce4c569934f8a6)
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',
213 'option_group_id' => [
214 'name' => 'option_group_id',
215 'type' => CRM_Utils_Type
::T_INT
,
216 'title' => ts('Option Group ID'),
217 'description' => ts('Group which this option belongs to.'),
219 'where' => 'civicrm_option_value.option_group_id',
220 'table_name' => 'civicrm_option_value',
221 'entity' => 'OptionValue',
222 'bao' => 'CRM_Core_BAO_OptionValue',
224 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
228 'pseudoconstant' => [
229 'table' => 'civicrm_option_group',
231 'labelColumn' => 'title',
232 'nameColumn' => 'name',
238 'type' => CRM_Utils_Type
::T_STRING
,
239 'title' => ts('Option Label'),
240 'description' => ts('Option string as displayed to users - e.g. the label in an HTML OPTION tag.'),
243 'size' => CRM_Utils_Type
::HUGE
,
244 'where' => 'civicrm_option_value.label',
245 'table_name' => 'civicrm_option_value',
246 'entity' => 'OptionValue',
247 'bao' => 'CRM_Core_BAO_OptionValue',
253 'type' => CRM_Utils_Type
::T_STRING
,
254 'title' => ts('Option Value'),
255 '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.'),
258 'size' => CRM_Utils_Type
::HUGE
,
259 'where' => 'civicrm_option_value.value',
260 'table_name' => 'civicrm_option_value',
261 'entity' => 'OptionValue',
262 'bao' => 'CRM_Core_BAO_OptionValue',
268 'type' => CRM_Utils_Type
::T_STRING
,
269 'title' => ts('Option Name'),
270 '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.'),
272 'size' => CRM_Utils_Type
::HUGE
,
274 'where' => 'civicrm_option_value.name',
276 'table_name' => 'civicrm_option_value',
277 'entity' => 'OptionValue',
278 'bao' => 'CRM_Core_BAO_OptionValue',
283 'name' => 'grouping',
284 'type' => CRM_Utils_Type
::T_STRING
,
285 'title' => ts('Option Grouping Name'),
286 '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.'),
288 'size' => CRM_Utils_Type
::HUGE
,
289 'where' => 'civicrm_option_value.grouping',
290 'table_name' => 'civicrm_option_value',
291 'entity' => 'OptionValue',
292 'bao' => 'CRM_Core_BAO_OptionValue',
298 'type' => CRM_Utils_Type
::T_INT
,
299 'title' => ts('Filter'),
300 'description' => ts('Bitwise logic can be used to create subsets of options within an option_group for different uses.'),
301 'where' => 'civicrm_option_value.filter',
303 'table_name' => 'civicrm_option_value',
304 'entity' => 'OptionValue',
305 'bao' => 'CRM_Core_BAO_OptionValue',
310 'name' => 'is_default',
311 'type' => CRM_Utils_Type
::T_BOOLEAN
,
312 'title' => ts('Option is Default?'),
313 'description' => ts('Is this the default option for the group?'),
314 'where' => 'civicrm_option_value.is_default',
316 'table_name' => 'civicrm_option_value',
317 'entity' => 'OptionValue',
318 'bao' => 'CRM_Core_BAO_OptionValue',
324 'type' => CRM_Utils_Type
::T_INT
,
325 'title' => ts('Order'),
326 'description' => ts('Controls display sort order.'),
328 'where' => 'civicrm_option_value.weight',
329 'table_name' => 'civicrm_option_value',
330 'entity' => 'OptionValue',
331 'bao' => 'CRM_Core_BAO_OptionValue',
336 'name' => 'description',
337 'type' => CRM_Utils_Type
::T_TEXT
,
338 'title' => ts('Option Description'),
339 'description' => ts('Optional description.'),
342 'where' => 'civicrm_option_value.description',
343 'table_name' => 'civicrm_option_value',
344 'entity' => 'OptionValue',
345 'bao' => 'CRM_Core_BAO_OptionValue',
348 'type' => 'TextArea',
353 'name' => 'is_optgroup',
354 'type' => CRM_Utils_Type
::T_BOOLEAN
,
355 'title' => ts('Option is Header?'),
356 '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?'),
357 'where' => 'civicrm_option_value.is_optgroup',
359 'table_name' => 'civicrm_option_value',
360 'entity' => 'OptionValue',
361 'bao' => 'CRM_Core_BAO_OptionValue',
366 'name' => 'is_reserved',
367 'type' => CRM_Utils_Type
::T_BOOLEAN
,
368 'title' => ts('Option Is Reserved?'),
369 'description' => ts('Is this a predefined system object?'),
370 'where' => 'civicrm_option_value.is_reserved',
372 'table_name' => 'civicrm_option_value',
373 'entity' => 'OptionValue',
374 'bao' => 'CRM_Core_BAO_OptionValue',
379 'name' => 'is_active',
380 'type' => CRM_Utils_Type
::T_BOOLEAN
,
381 'title' => ts('Option Is Active'),
382 'description' => ts('Is this option active?'),
383 'where' => 'civicrm_option_value.is_active',
385 'table_name' => 'civicrm_option_value',
386 'entity' => 'OptionValue',
387 'bao' => 'CRM_Core_BAO_OptionValue',
392 'name' => 'component_id',
393 'type' => CRM_Utils_Type
::T_INT
,
394 'title' => ts('Option Component'),
395 'description' => ts('Component that this option value belongs/caters to.'),
396 'where' => 'civicrm_option_value.component_id',
397 'table_name' => 'civicrm_option_value',
398 'entity' => 'OptionValue',
399 'bao' => 'CRM_Core_BAO_OptionValue',
401 'FKClassName' => 'CRM_Core_DAO_Component',
405 'pseudoconstant' => [
406 'table' => 'civicrm_component',
408 'labelColumn' => 'name',
413 'name' => 'domain_id',
414 'type' => CRM_Utils_Type
::T_INT
,
415 'title' => ts('Option Domain'),
416 'description' => ts('Which Domain is this option value for'),
417 'where' => 'civicrm_option_value.domain_id',
418 'table_name' => 'civicrm_option_value',
419 'entity' => 'OptionValue',
420 'bao' => 'CRM_Core_BAO_OptionValue',
422 'FKClassName' => 'CRM_Core_DAO_Domain',
423 'pseudoconstant' => [
424 'table' => 'civicrm_domain',
426 'labelColumn' => 'name',
431 'name' => 'visibility_id',
432 'type' => CRM_Utils_Type
::T_INT
,
433 'title' => ts('Option Visibility'),
434 'where' => 'civicrm_option_value.visibility_id',
436 'table_name' => 'civicrm_option_value',
437 'entity' => 'OptionValue',
438 'bao' => 'CRM_Core_BAO_OptionValue',
440 'pseudoconstant' => [
441 'optionGroupName' => 'visibility',
442 'optionEditPath' => 'civicrm/admin/options/visibility',
448 'type' => CRM_Utils_Type
::T_STRING
,
449 'title' => ts('Icon'),
450 'description' => ts('crm-i icon class'),
452 'size' => CRM_Utils_Type
::HUGE
,
453 'where' => 'civicrm_option_value.icon',
455 'table_name' => 'civicrm_option_value',
456 'entity' => 'OptionValue',
457 'bao' => 'CRM_Core_BAO_OptionValue',
463 'type' => CRM_Utils_Type
::T_STRING
,
464 'title' => ts('Color'),
465 'description' => ts('Hex color value e.g. #ffffff'),
467 'size' => CRM_Utils_Type
::HUGE
,
468 'where' => 'civicrm_option_value.color',
470 'table_name' => 'civicrm_option_value',
471 'entity' => 'OptionValue',
472 'bao' => 'CRM_Core_BAO_OptionValue',
477 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
479 return Civi
::$statics[__CLASS__
]['fields'];
483 * Return a mapping from field-name to the corresponding key (as used in fields()).
486 * Array(string $name => string $uniqueName).
488 public static function &fieldKeys() {
489 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
490 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
492 return Civi
::$statics[__CLASS__
]['fieldKeys'];
496 * Returns the names of this table
500 public static function getTableName() {
501 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
505 * Returns if this table needs to be logged
509 public function getLog() {
514 * Returns the list of fields that can be imported
516 * @param bool $prefix
520 public static function &import($prefix = FALSE) {
521 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'option_value', $prefix, []);
526 * Returns the list of fields that can be exported
528 * @param bool $prefix
532 public static function &export($prefix = FALSE) {
533 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'option_value', $prefix, []);
538 * Returns the list of indices
540 * @param bool $localize
544 public static function indices($localize = TRUE) {
546 'index_option_group_id_value' => [
547 'name' => 'index_option_group_id_value',
550 1 => 'option_group_id',
552 'localizable' => FALSE,
553 'sig' => 'civicrm_option_value::0::value(128)::option_group_id',
555 'index_option_group_id_name' => [
556 'name' => 'index_option_group_id_name',
559 1 => 'option_group_id',
561 'localizable' => FALSE,
562 'sig' => 'civicrm_option_value::0::name(128)::option_group_id',
565 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;