ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAdvancedMDRecordObjectOrdering.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
25{
26 private int $record_id;
27 private int $obj_id;
28 private int $position = 0;
29
30 protected ilDBInterface $db;
31
32 public function __construct(int $record_id, int $obj_id, ilDBInterface $db)
33 {
34 $this->record_id = $record_id;
35 $this->obj_id = $obj_id;
36 $this->db = $db;
37 }
38
39 public function setPosition(int $position): void
40 {
41 $this->position = $position;
42 }
43
44 public function getPosition(): int
45 {
46 return $this->position;
47 }
48
53 public function save(): void
54 {
55 $this->delete();
56
57 $query = 'INSERT INTO adv_md_record_obj_ord (record_id, obj_id, position ) ' .
58 'VALUES ( ' .
59 $this->db->quote($this->record_id, 'integer') . ', ' .
60 $this->db->quote($this->obj_id, 'integer') . ', ' .
61 $this->db->quote($this->position, 'integer') . ' ' .
62 ')';
63
64 $this->db->manipulate($query);
65 }
66
70 public function delete(): void
71 {
72 $query = 'DELETE FROM adv_md_record_obj_ord WHERE ' .
73 'record_id = ' . $this->db->quote($this->record_id, 'integer') . ' ' .
74 'AND obj_id = ' . $this->db->quote($this->obj_id, 'integer');
75 $this->db->manipulate($query);
76 }
77}
__construct(int $record_id, int $obj_id, ilDBInterface $db)
Interface ilDBInterface.