31 public function __construct($a_parent_obj, $a_parent_cmd, $a_records, $a_mode =
"chronological")
35 $this->
ctrl = $DIC->ctrl();
36 $this->
lng = $DIC->language();
37 $this->
access = $DIC->access();
38 $ilCtrl = $DIC->ctrl();
39 $lng = $DIC->language();
40 $ilAccess = $DIC->access();
41 $lng = $DIC->language();
45 $this->mode = $a_mode;
47 switch ($this->mode) {
62 case "by_first_table":
81 $this->
setRowTemplate(
"tpl.db_bench.html",
"Modules/SystemFolder");
89 public function getFirst(
string $a_str, array $a_needles):
int 92 foreach ($a_needles as $needle) {
93 $pos2 = strpos($a_str, (
string) $needle);
95 if ($pos2 > 0 && ($pos2 < $pos || $pos === 0)) {
108 $pos1 = $this->
getFirst(strtolower($a_sql), [
"from ",
"from\n",
"from\t",
"from\r"]);
112 $tablef = substr(strtolower($a_sql), $pos1 + 5);
113 $pos2 = $this->
getFirst($tablef, [
" ",
"\n",
"\t",
"\r"]);
114 $table = $pos2 > 0 ? substr($tablef, 0, $pos2) : $tablef;
116 if (trim($table) !==
"") {
129 foreach ($a_records as $r) {
131 if (trim($table) ===
'') {
134 $data[$table][
"table"] = $table;
135 if (!isset(
$data[$table][
"cnt"])) {
136 $data[$table][
"cnt"] = 1;
138 $data[$table][
"cnt"]++;
140 if (!isset(
$data[$table][
"time"])) {
141 $data[$table][
"time"] = $r[
"time"];
143 $data[$table][
"time"] += $r[
"time"];
156 protected function fillRow(array $a_set): void
160 switch ($this->mode) {
161 case "by_first_table":
162 $this->tpl->setCurrentBlock(
"td");
163 $this->tpl->setVariable(
"VAL", $a_set[
"table"]);
164 $this->tpl->parseCurrentBlock();
165 $this->tpl->setVariable(
"VAL1", $a_set[
"time"]);
166 $this->tpl->setVariable(
"VAL2", $a_set[
"cnt"]);
169 case "slowest_first":
170 case "sorted_by_sql":
172 $this->tpl->setVariable(
"VAL1", $a_set[
"time"]);
173 $this->tpl->setVariable(
"VAL2", $a_set[
"sql"]);
extractFirstTableFromSQL(string $a_sql)
Extract first table from sql.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setFormAction(string $a_form_action, bool $a_multipart=false)
__construct($a_parent_obj, $a_parent_cmd, $a_records, $a_mode="chronological")
Constructor.
setEnableTitle(bool $a_enabletitle)
fillRow(array $a_set)
Fill table row.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDataByFirstTable(array $a_records)
Get data by first table.
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(Container $dic, ilPlugin $plugin)
setLimit(int $a_limit=0, int $a_default_limit=0)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
disable(string $a_module_name)
getFirst(string $a_str, array $a_needles)
Get first occurence of string.
setEnableHeader(bool $a_enableheader)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)