ILIAS  release_8 Revision v8.24
class.ilNotesDBUpdateSteps.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\Notes\Setup;
20
22{
23 protected \ilDBInterface $db;
24
25 public function prepare(\ilDBInterface $db): void
26 {
27 $this->db = $db;
28 }
29
30 public function step_1(): void
31 {
32 $db = $this->db;
33 $set1 = $db->queryF(
34 "SELECT * FROM note_settings " .
35 " WHERE obj_type = %s AND obj_id = %s",
36 ["text", "integer"],
37 ["0", "0"]
38 );
39 while ($rec1 = $db->fetchAssoc($set1)) {
40 // get type
41 $set2 = $db->queryF(
42 "SELECT type FROM object_data " .
43 " WHERE obj_id = %s ",
44 ["integer"],
45 [$rec1["rep_obj_id"]]
46 );
47 if ($rec2 = $db->fetchAssoc($set2)) {
48
49 // get activation with current query
50 $set3 = $db->query(
51 "SELECT rep_obj_id FROM note_settings " .
52 " WHERE rep_obj_id = " . $db->quote($rec1["rep_obj_id"], "integer") .
53 " AND activated = " . $db->quote(1, "integer")
54 );
55 $active = 0;
56 if ($db->fetchAssoc($set3)) {
57 $active = 1;
58 }
59 $db->replace(
60 "note_settings",
61 [
62 "rep_obj_id" => ["integer", $rec1["rep_obj_id"]],
63 "obj_id" => ["integer", $rec1["obj_id"]]
64 ],
65 [
66 "obj_type" => ["text", $rec2["type"]],
67 "activated" => ["integer", $active],
68 ]
69 );
71 "DELETE FROM note_settings WHERE " .
72 " rep_obj_id = %s AND obj_id = %s AND obj_type = %s",
73 ["integer", "integer", "text"],
74 [$rec1["rep_obj_id"], $rec1["obj_id"], $rec1["obj_type"]]
75 );
76
77 }
78 }
79 }
80}
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
Interface ilDBInterface.
replace(string $table, array $primary_keys, array $other_columns)
Replace into method.
quote($value, string $type)
manipulateF(string $query, array $types, array $values)
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.Agent.php:21