ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ColorDBRepo.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Style\Content;
22
24
29{
30 protected ilDBInterface $db;
32
33 public function __construct(
36 ) {
37 $this->db = $db;
38 $this->factory = $factory;
39 }
40
41 public function addColor(
42 int $style_id,
43 string $a_name,
44 string $a_code
45 ): void {
46 $db = $this->db;
47
48 $db->insert("style_color", [
49 "style_id" => ["integer", $style_id],
50 "color_name" => ["text", $a_name],
51 "color_code" => ["text", $a_code]
52 ]);
53 }
54
58 public function colorExists(
59 int $style_id,
60 string $a_color_name
61 ): bool {
62 $db = $this->db;
63
64 $set = $db->query("SELECT * FROM style_color WHERE " .
65 "style_id = " . $db->quote($style_id, "integer") . " AND " .
66 "color_name = " . $db->quote($a_color_name, "text"));
67 if ($db->fetchAssoc($set)) {
68 return true;
69 }
70 return false;
71 }
72
73 public function updateColor(
74 int $style_id,
75 string $name,
76 string $new_name,
77 string $code
78 ): void {
79 $db = $this->db;
80
81 $db->update(
82 "style_color",
83 [
84 "color_name" => ["text", $new_name],
85 "color_code" => ["text", $code]
86 ],
87 [ // where
88 "style_id" => ["integer", $style_id],
89 "color_name" => ["text", $name]
90 ]
91 );
92 }
93}
factory()
addColor(int $style_id, string $a_name, string $a_code)
updateColor(int $style_id, string $name, string $new_name, string $code)
__construct(ilDBInterface $db, InternalDataService $factory)
colorExists(int $style_id, string $a_color_name)
Check whether color exists.
Interface ilDBInterface.
update(string $table_name, array $values, array $where)
@description $where MUST contain existing columns only.
insert(string $table_name, array $values)