ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
UsageDBRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
25 protected \ilDBInterface $db;
26
27 public function __construct(
29 ) {
30 $this->db = $db;
31 }
32
33 public function getUsageOfObject(int $obj_id, bool $include_titles = false): array
34 {
35 $set = $this->db->query(
36 "SELECT tax_id FROM tax_usage " .
37 " WHERE obj_id = " . $this->db->quote($obj_id, "integer")
38 );
39 $tax = array();
40 while ($rec = $this->db->fetchAssoc($set)) {
41 if (!$include_titles) {
42 $tax[] = (int) $rec["tax_id"];
43 } else {
44 $tax[] = array("tax_id" => (int) $rec["tax_id"],
45 "title" => \ilObject::_lookupTitle((int) $rec["tax_id"])
46 );
47 }
48 }
49 if ($include_titles) {
50 $tax = \ilArrayUtil::sortArray($tax, "title");
51 }
52 return $tax;
53 }
54
55}
getUsageOfObject(int $obj_id, bool $include_titles=false)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static _lookupTitle(int $obj_id)
Interface ilDBInterface.