added new module rml-workorder

This commit is contained in:
Luca Haid
2025-06-29 20:32:28 +02:00
parent 8d4e12e441
commit c629c9d38b
11 changed files with 983 additions and 0 deletions

View File

@@ -203,4 +203,26 @@ class TTCrudBaseModel {
return $db->affected_rows;
}
public static function getFirst($filter = [], $order = ["key" => null]): ?TTCrudBaseModel {
$db = self::getDB();
$table = self::getFullyQualifiedTable();
$filter = self::getSQLFilter($filter);
$sql = "SELECT * FROM $table $filter";
if ($order['key'] !== null) {
$sql .= " ORDER BY `" . $order['key'] . "` " . $order['order'];
} else {
$sql .= " ORDER BY `id` ASC";
}
$sql .= " LIMIT 1";
$result = $db->query($sql);
if ($result->num_rows === 0) {
return null;
}
return new static($result->fetch_assoc());
}
}