ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ReadingTimeDBRepo.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /* Copyright (c) 1998-2022 ILIAS open source, GPLv3, see LICENSE */
6 
7 namespace ILIAS\Blog\ReadingTime;
8 
13 {
14  protected \ilDBInterface $db;
15 
16  public function __construct()
17  {
18  global $DIC;
19  $this->db = $DIC->database();
20  }
21 
22  public function isActivated(int $lm_id): bool
23  {
24  $db = $this->db;
25  $set = $db->queryF(
26  "SELECT act_est_reading_time FROM il_blog " .
27  " WHERE id = %s ",
28  ["integer"],
29  [$lm_id]
30  );
31  if ($rec = $db->fetchAssoc($set)) {
32  return (bool) $rec["act_est_reading_time"];
33  }
34  return false;
35  }
36 
37  public function activate(int $lm_id, bool $activated): void
38  {
39  $db = $this->db;
40  $db->update(
41  "il_blog",
42  [
43  "act_est_reading_time" => ["integer", $activated]
44  ],
45  [ // where
46  "id" => ["integer", $lm_id]
47  ]
48  );
49  }
50 }
update(string $table_name, array $values, array $where)
$where MUST contain existing columns only.
global $DIC
Definition: feed.php:28
queryF(string $query, array $types, array $values)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...