Create sorting on table in devices

This commit is contained in:
Haitem
2020-09-09 20:24:10 +02:00
parent ed732e125a
commit cc804f36df
3 changed files with 160 additions and 80 deletions

View File

@@ -26,6 +26,10 @@ class DeviceManager{
return Db::loadOne("SELECT * FROM devices WHERE device_id = ?", array($deviceId));
}
static function getAllDevicesSorted ($sort, $sortType = "ASC") {
return Db::loadAll ("SELECT devices.* FROM devices LEFT JOIN rooms ON devices.room_id = rooms.room_id WHERE devices.approved != ? ORDER BY $sort $sortType", Array(2));
}
public static function create ($name, $token) {
$defaultRoom = RoomManager::getDefaultRoomId();
$device = array (