5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/Tag.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:68e222188dd1d031d2219aa1617e15af)
13 * Database access object for the Tag entity.
15 class CRM_Core_DAO_Tag
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_tag';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-tag';
34 * Field to show when displaying a record.
38 public static $_labelField = 'name';
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
45 public static $_log = TRUE;
50 * @var int|string|null
51 * (SQL type: int unsigned)
52 * Note that values will be retrieved from the database as a string.
60 * (SQL type: varchar(64))
61 * Note that values will be retrieved from the database as a string.
66 * Optional verbose description of the tag.
69 * (SQL type: varchar(255))
70 * Note that values will be retrieved from the database as a string.
75 * Optional parent id for this tag.
77 * @var int|string|null
78 * (SQL type: int unsigned)
79 * Note that values will be retrieved from the database as a string.
84 * Is this tag selectable / displayed
88 * Note that values will be retrieved from the database as a string.
90 public $is_selectable;
95 * Note that values will be retrieved from the database as a string.
101 * (SQL type: tinyint)
102 * Note that values will be retrieved from the database as a string.
108 * (SQL type: varchar(64))
109 * Note that values will be retrieved from the database as a string.
114 * FK to civicrm_contact, who created this tag
116 * @var int|string|null
117 * (SQL type: int unsigned)
118 * Note that values will be retrieved from the database as a string.
123 * Hex color value e.g. #ffffff
126 * (SQL type: varchar(255))
127 * Note that values will be retrieved from the database as a string.
132 * Date and time that tag was created.
135 * (SQL type: datetime)
136 * Note that values will be retrieved from the database as a string.
138 public $created_date;
143 public function __construct() {
144 $this->__table
= 'civicrm_tag';
145 parent
::__construct();
149 * Returns localized title of this entity.
151 * @param bool $plural
152 * Whether to return the plural version of the title.
154 public static function getEntityTitle($plural = FALSE) {
155 return $plural ?
ts('Tags') : ts('Tag');
159 * Returns foreign keys and entity references.
162 * [CRM_Core_Reference_Interface]
164 public static function getReferenceColumns() {
165 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
166 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
167 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_tag', 'id');
168 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
169 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
171 return Civi
::$statics[__CLASS__
]['links'];
175 * Returns all the column names of this table
179 public static function &fields() {
180 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
181 Civi
::$statics[__CLASS__
]['fields'] = [
184 'type' => CRM_Utils_Type
::T_INT
,
185 'title' => ts('Tag ID'),
186 'description' => ts('Tag ID'),
188 'where' => 'civicrm_tag.id',
189 'table_name' => 'civicrm_tag',
191 'bao' => 'CRM_Core_BAO_Tag',
201 'type' => CRM_Utils_Type
::T_STRING
,
202 'title' => ts('Tag Name'),
203 'description' => ts('Name of Tag.'),
206 'size' => CRM_Utils_Type
::BIG
,
207 'where' => 'civicrm_tag.name',
208 'table_name' => 'civicrm_tag',
210 'bao' => 'CRM_Core_BAO_Tag',
215 'name' => 'description',
216 'type' => CRM_Utils_Type
::T_STRING
,
217 'title' => ts('Description'),
218 'description' => ts('Optional verbose description of the tag.'),
220 'size' => CRM_Utils_Type
::HUGE
,
221 'where' => 'civicrm_tag.description',
222 'table_name' => 'civicrm_tag',
224 'bao' => 'CRM_Core_BAO_Tag',
229 'name' => 'parent_id',
230 'type' => CRM_Utils_Type
::T_INT
,
231 'title' => ts('Parent Tag ID'),
232 'description' => ts('Optional parent id for this tag.'),
233 'where' => 'civicrm_tag.parent_id',
235 'table_name' => 'civicrm_tag',
237 'bao' => 'CRM_Core_BAO_Tag',
239 'FKClassName' => 'CRM_Core_DAO_Tag',
241 'label' => ts("Parent Tag"),
243 'pseudoconstant' => [
244 'table' => 'civicrm_tag',
246 'labelColumn' => 'name',
251 'name' => 'is_selectable',
252 'type' => CRM_Utils_Type
::T_BOOLEAN
,
253 'title' => ts('Display Tag?'),
254 'description' => ts('Is this tag selectable / displayed'),
256 'where' => 'civicrm_tag.is_selectable',
258 'table_name' => 'civicrm_tag',
260 'bao' => 'CRM_Core_BAO_Tag',
265 'name' => 'is_reserved',
266 'type' => CRM_Utils_Type
::T_BOOLEAN
,
267 'title' => ts('Reserved'),
269 'where' => 'civicrm_tag.is_reserved',
271 'table_name' => 'civicrm_tag',
273 'bao' => 'CRM_Core_BAO_Tag',
278 'name' => 'is_tagset',
279 'type' => CRM_Utils_Type
::T_BOOLEAN
,
280 'title' => ts('Tagset'),
282 'where' => 'civicrm_tag.is_tagset',
284 'table_name' => 'civicrm_tag',
286 'bao' => 'CRM_Core_BAO_Tag',
291 'name' => 'used_for',
292 'type' => CRM_Utils_Type
::T_STRING
,
293 'title' => ts('Used For'),
295 'size' => CRM_Utils_Type
::BIG
,
296 'where' => 'civicrm_tag.used_for',
298 'table_name' => 'civicrm_tag',
300 'bao' => 'CRM_Core_BAO_Tag',
302 'serialize' => self
::SERIALIZE_COMMA
,
306 'pseudoconstant' => [
307 'optionGroupName' => 'tag_used_for',
308 'optionEditPath' => 'civicrm/admin/options/tag_used_for',
313 'name' => 'created_id',
314 'type' => CRM_Utils_Type
::T_INT
,
315 'title' => ts('Created By Contact ID'),
316 'description' => ts('FK to civicrm_contact, who created this tag'),
317 'where' => 'civicrm_tag.created_id',
318 'table_name' => 'civicrm_tag',
320 'bao' => 'CRM_Core_BAO_Tag',
322 'FKClassName' => 'CRM_Contact_DAO_Contact',
324 'label' => ts("Created By"),
330 'type' => CRM_Utils_Type
::T_STRING
,
331 'title' => ts('Color'),
332 'description' => ts('Hex color value e.g. #ffffff'),
334 'size' => CRM_Utils_Type
::HUGE
,
335 'where' => 'civicrm_tag.color',
337 'table_name' => 'civicrm_tag',
339 'bao' => 'CRM_Core_BAO_Tag',
344 'name' => 'created_date',
345 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
346 'title' => ts('Tag Created Date'),
347 'description' => ts('Date and time that tag was created.'),
348 'where' => 'civicrm_tag.created_date',
349 'table_name' => 'civicrm_tag',
351 'bao' => 'CRM_Core_BAO_Tag',
356 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
358 return Civi
::$statics[__CLASS__
]['fields'];
362 * Return a mapping from field-name to the corresponding key (as used in fields()).
365 * Array(string $name => string $uniqueName).
367 public static function &fieldKeys() {
368 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
369 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
371 return Civi
::$statics[__CLASS__
]['fieldKeys'];
375 * Returns the names of this table
379 public static function getTableName() {
380 return self
::$_tableName;
384 * Returns if this table needs to be logged
388 public function getLog() {
393 * Returns the list of fields that can be imported
395 * @param bool $prefix
399 public static function &import($prefix = FALSE) {
400 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'tag', $prefix, []);
405 * Returns the list of fields that can be exported
407 * @param bool $prefix
411 public static function &export($prefix = FALSE) {
412 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'tag', $prefix, []);
417 * Returns the list of indices
419 * @param bool $localize
423 public static function indices($localize = TRUE) {
430 'localizable' => FALSE,
432 'sig' => 'civicrm_tag::1::name',
435 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;