public function getlightsAction() { require_once 'models/homeModel.php'; $model = new homeModel(); $user = $model->getUser($_SESSION[user_id]); if ($user['room'] == 0) { $lights = $model->getActivDevices(); } else { $lights = $model->getLampsByRoomId($user['room']); } //$lights = $model->getActivDevices(); foreach ($lights as $lamp) { $arr['id'] = $lamp['id']; $arr['room_id'] = $lamp['room_id']; $arr['device'] = $lamp['device']; $arr['status'] = $lamp['status']; $arr['sunset'] = $lamp['sunset']; $room = $model->getRoomNameById($lamp['room_id']); $arr['room'] = $room; $array[] = $arr; } echo json_encode($array); //echo json_encode($user['room']); }
public function getlightsAction() { require_once 'models/homeModel.php'; $model = new homeModel(); $lights = $model->getActivDevices(); foreach ($lights as $lamp) { $arr['id'] = $lamp['id']; $arr['room_id'] = $lamp['room_id']; $arr['device'] = $lamp['device']; $arr['status'] = $lamp['status']; $arr['sunset'] = $lamp['sunset']; $room = $model->getRoomNameById($lamp['room_id']); $arr['room'] = $room; $array[] = $arr; } echo json_encode($array); }