ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAdvancedMDRecordObjectOrdering.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
15  private $record_id;
16 
20  private $obj_id;
21 
25  private $position;
26 
27 
31  private $db;
32 
33 
39  public function __construct(int $record_id, int $obj_id, ilDBInterface $db)
40  {
41  $this->record_id = $record_id;
42  $this->obj_id = $obj_id;
43 
44  $this->db = $db;
45  }
46 
50  public function setPosition(int $position)
51  {
52  $this->position = $position;
53  }
54 
58  public function getPosition() : int
59  {
60  return $this->position;
61  }
62 
67  public function save()
68  {
69  $this->delete();
70 
71  $query = 'INSERT INTO adv_md_record_obj_ord (record_id, obj_id, position ) ' .
72  'VALUES ( ' .
73  $this->db->quote($this->record_id, 'integer') . ', ' .
74  $this->db->quote($this->obj_id, 'integer') . ', ' .
75  $this->db->quote($this->position, 'integer') . ' ' .
76  ')';
77 
78  $this->db->manipulate($query);
79  }
80 
84  public function delete()
85  {
86  $query = 'DELETE FROM adv_md_record_obj_ord WHERE ' .
87  'record_id = ' . $this->db->quote($this->record_id, 'integer') . ' ' .
88  'AND obj_id = ' . $this->db->quote($this->obj_id, 'integer');
89  $this->db->manipulate($query);
90  }
91 }
$query
__construct(int $record_id, int $obj_id, ilDBInterface $db)
ilAdvancedMDRecordObjectOrdering constructor.