ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAdvancedMDRecordObjectOrdering.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
5 
11 {
12  private int $record_id;
13  private int $obj_id;
14  private int $position = 0;
15 
16  protected ilDBInterface $db;
17 
18  public function __construct(int $record_id, int $obj_id, ilDBInterface $db)
19  {
20  $this->record_id = $record_id;
21  $this->obj_id = $obj_id;
22  $this->db = $db;
23  }
24 
25  public function setPosition(int $position): void
26  {
27  $this->position = $position;
28  }
29 
30  public function getPosition(): int
31  {
32  return $this->position;
33  }
34 
39  public function save(): void
40  {
41  $this->delete();
42 
43  $query = 'INSERT INTO adv_md_record_obj_ord (record_id, obj_id, position ) ' .
44  'VALUES ( ' .
45  $this->db->quote($this->record_id, 'integer') . ', ' .
46  $this->db->quote($this->obj_id, 'integer') . ', ' .
47  $this->db->quote($this->position, 'integer') . ' ' .
48  ')';
49 
50  $this->db->manipulate($query);
51  }
52 
56  public function delete(): void
57  {
58  $query = 'DELETE FROM adv_md_record_obj_ord WHERE ' .
59  'record_id = ' . $this->db->quote($this->record_id, 'integer') . ' ' .
60  'AND obj_id = ' . $this->db->quote($this->obj_id, 'integer');
61  $this->db->manipulate($query);
62  }
63 }
$query
__construct(int $record_id, int $obj_id, ilDBInterface $db)