ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilPortfolioDBUpdateSteps.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\Portfolio\Setup;
20
25{
26 protected \ilDBInterface $db;
27
28 public function prepare(\ilDBInterface $db): void
29 {
30 $this->db = $db;
31 }
32
33 public function step_1(): void
34 {
35 $db = $this->db;
36 if (!$db->tableExists('prtf_role_assignment')) {
37 $fields = [
38 'role_id' => [
39 'type' => 'integer',
40 'length' => 4,
41 'notnull' => true,
42 'default' => 0
43 ],
44 'template_ref_id' => [
45 'type' => 'integer',
46 'length' => 4,
47 'notnull' => true,
48 'default' => 0
49 ]
50 ];
51 $db->createTable('prtf_role_assignment', $fields);
52 $db->addPrimaryKey('prtf_role_assignment', ['role_id', 'template_ref_id']);
53 }
54 }
55
56 public function step_2(): void
57 {
58 $db = $this->db;
60 "DELETE FROM usr_portfolio_page WHERE " .
61 " type = %s",
62 ["integer"],
63 [2]
64 );
65 }
66
67 public function step_3(): void
68 {
69 $db = $this->db;
70
71 $set = $db->query("SELECT * FROM usr_portfolio");
72 while ($rec = $db->fetchAssoc($set)) {
73 $offline = ($rec["is_online"] == 1) ? 0 : 1;
74 $db->update(
75 "object_data",
76 [
77 "offline" => ["integer", $offline]
78 ],
79 [
80 "obj_id" => ["integer", $rec["id"]],
81 "type" => ["text", "prtf"]
82 ]
83 );
84
85 }
86 }
87
88}
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
Interface ilDBInterface.
update(string $table_name, array $values, array $where)
@description $where MUST contain existing columns only.
tableExists(string $table_name)
manipulateF(string $query, array $types, array $values)
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)
createTable(string $table_name, array $fields, bool $drop_table=false, bool $ignore_erros=false)
addPrimaryKey(string $table_name, array $primary_keys)
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:19