mirror of
https://git.steelants.cz/SH/PHP_SMART_HOME_V3.git
synced 2026-10-11 17:54:34 +00:00
CleanUp After Docker Try
This commit is contained in:
1 parent
2f638d8091
commit
090b9f7a7b
123 files changed
+5265
No files matched your search
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
class RoomManager{
|
||||
public static $rooms;
|
||||
|
||||
static function getDefaultRoomId() {
|
||||
$defaultRoom = Db::loadOne("SELECT room_id FROM rooms WHERE 'default' = 1");
|
||||
return $defaultRoom['room_id'];
|
||||
}
|
||||
|
||||
static function getAllRooms () {
|
||||
$allRoom = Db::loadAll ("SELECT rooms.*, COUNT(devices.device_id) as device_count FROM rooms LEFT JOIN devices ON (devices.room_id=rooms.room_id) GROUP BY rooms.room_id");
|
||||
return $allRoom;
|
||||
}
|
||||
|
||||
public static function create ($name) {
|
||||
$room = array (
|
||||
'name' => $name,
|
||||
);
|
||||
try {
|
||||
Db::add ('rooms', $room);
|
||||
} catch(PDOException $error) {
|
||||
echo $error->getMessage();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
public static function delete ($roomId) {
|
||||
Db::command ('DELETE FROM rooms WHERE room_id=?', array ($roomId));
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in new issue
Block a user