initial
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Reservair\Database\Db;
|
||||
|
||||
class RsvFormSubmitRepository {
|
||||
private string $table;
|
||||
|
||||
public function __construct() {
|
||||
$this->table = Db::prefix() . 'rsv_form_submit';
|
||||
}
|
||||
|
||||
public function add(int $form_id, array $values): int {
|
||||
return Db::insert($this->table, [
|
||||
'form_id' => $form_id,
|
||||
'values' => json_encode($values),
|
||||
]);
|
||||
}
|
||||
|
||||
public function delete(int $id): void {
|
||||
Db::delete($this->table, ['form_submit_id' => $id]);
|
||||
}
|
||||
|
||||
public function get(int $id): ?array {
|
||||
$row = Db::get_row(
|
||||
"SELECT * FROM {$this->table} WHERE form_submit_id = %d",
|
||||
[$id],
|
||||
ARRAY_A
|
||||
);
|
||||
|
||||
if ($row === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$row['values'] = json_decode($row['values'], true);
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user