4in1_ws_web/lib/previous_texts.php

27 lines
762 B
PHP

<?php
class previous_texts {
public static function add(int $object_type, int $object_id, string $md, int $ts) {
$db = DB();
$db->insert(PreviousText::DB_TABLE, [
'object_type' => $object_type,
'object_id' => $object_id,
'md' => $md,
'ts' => $ts
]);
}
public static function delete(int $object_type, int|array $object_id): void {
$sql = "DELETE FROM ".PreviousText::DB_TABLE." WHERE object_type=? AND object_id";
$args = [$object_type];
if (is_array($object_id))
$sql .= " IN (".implode(',', $object_id).")";
else {
$sql .= '=?';
$args[] = $object_id;
}
DB()->query($sql, ...$args);
}
}