42 lines
1.0 KiB
PHP
42 lines
1.0 KiB
PHP
<?php
|
|
|
|
class PreviousText extends model {
|
|
|
|
const DB_TABLE = 'previous_texts';
|
|
|
|
const int TYPE_POST_TEXT = 0x0;
|
|
const int TYPE_PAGE = 0x1;
|
|
|
|
public int $id;
|
|
public int $objectType;
|
|
public string $objectId;
|
|
public string $md;
|
|
public int $ts;
|
|
|
|
}
|
|
|
|
class previous_texts {
|
|
|
|
static function add(int $object_type, int|string $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
|
|
]);
|
|
}
|
|
|
|
static function delete(int $object_type, int|string|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);
|
|
}
|
|
|
|
} |