3 declare(strict_types=1);
24 $this->db = $DIC->database();
26 $this->
logger = $DIC->logger()->amet();
28 $this->scope_id = $a_scope_id;
34 $this->record_id = $a_record_id;
44 $this->scope_id = $a_scope_id;
54 $this->ref_id = $a_ref_id;
62 public function save(): void
65 $this->scope_id = $this->db->nextId(
'adv_md_record_scope');
66 $query =
'INSERT INTO adv_md_record_scope (scope_id, record_id, ref_id) ' .
68 $this->db->quote($this->scope_id,
'integer') .
', ' .
69 $this->db->quote($this->record_id,
'integer') .
', ' .
70 $this->db->quote($this->ref_id,
'integer') .
72 $this->db->manipulate(
$query);
77 $this->
logger->debug(
'Update entry.');
79 $query =
'UPDATE adv_md_record_scope ' .
80 'SET ref_id = ' . $this->db->quote($this->ref_id,
'integer') .
' ' .
81 'WHERE scope_id = ' . $this->db->quote($this->scope_id,
'integer');
82 $this->db->manipulate(
$query);
85 public function delete():
void 87 $query =
'DELETE FROM adv_md_record_scope ' .
88 'WHERE scope_id = ' . $this->db->quote($this->scope_id,
'integer');
89 $this->db->manipulate(
$query);
95 $db = $DIC->database();
97 $query =
'DELETE FROM adv_md_record_scope ' .
98 'WHERE record_id = ' . $db->
quote($a_record_id,
'integer');
102 protected function read(): void
104 if (!$this->scope_id) {
107 $query =
'SELECT * FROM adv_md_record_scope ' .
108 'WHERE scope_id = ' . $this->db->quote($this->scope_id,
'integer');
111 $this->record_id = (
int) $row->record_id;
112 $this->ref_id = (
int) $row->ref_id;
__construct(int $a_scope_id=0)
Scope restrictions for advanced md records.
quote($value, string $type)
static deleteByRecordId(int $a_record_id)
setScopeId(int $a_scope_id)
setRecordId(int $a_record_id)
manipulate(string $query)
Run a (write) Query on the database.