Php Laravel4.2从mysql表中检索数据
对于我的项目,我需要根据mysql表中的命令列和系统id以及表中列出的当前值来获取温度 我正在将这些值传递到.blade.php,并尝试在我的网站上显示这些值 在我的BuildingController.php中,我有以下函数Php Laravel4.2从mysql表中检索数据,php,mysql,laravel-4,Php,Mysql,Laravel 4,对于我的项目,我需要根据mysql表中的命令列和系统id以及表中列出的当前值来获取温度 我正在将这些值传递到.blade.php,并尝试在我的网站上显示这些值 在我的BuildingController.php中,我有以下函数 public static function furnaceMap($building_id, $system_id) { $data['thisBldg'] = Building::find($building_id); $data['th
public static function furnaceMap($building_id, $system_id)
{
$data['thisBldg'] = Building::find($building_id);
$data['thisSystem'] = System::find($system_id);
$data['boiler'] = 'boiler.jpg';
$currentData = DeviceDataCurrent::where('system_id', $system_id)
->where('command', '1') //i am only getting command 1 values
->orderby('id','ASC','command','ASC')
//->take(100)
->get();
$currentData = DeviceDataCurrent::where('system_id', $system_id);
$currentData->whereIn('command', function($subquery)
{
$subquery->from('device_types')
->select('command')
->where('function', 'Temperature');
});
$currentData =$currentData
->orderby('id','ASC','command','ASC')
->get();
//dd($currentData -> toArray());
$data['apartments'] = [
['x-pos'=>"100", 'y-pos'=>"80" , 'state'=>"success", 'name'=>"Apt1" ,'tag'=>"Temperature:", 'temp'=>"76" ."°"."F", 'status'=>"On" , 'high'=>"80" , 'low'=>"70" , 'location'=>"loc", 'systemID'=>"xxxxxx" ],
['x-pos'=>"250", 'y-pos'=>"80" , 'state'=>"warning", 'name'=>"Apt2" ,'tag'=>"Temperature:", 'temp'=>"77" ."°"."F", 'status'=>"On" , 'high'=>"80" , 'low'=>"70" , 'location'=>"loc", 'systemID'=>"xxxxxx" ],
['x-pos'=>"400", 'y-pos'=>"80" , 'state'=>"success", 'name'=>"Apt3" ,'tag'=>"Temperature:", 'temp'=>"55" ."°"."F", 'status'=>"Off", 'high'=>"80" , 'low'=>"45" , 'location'=>"loc", 'systemID'=>"xxxxxx" ],
['x-pos'=>"550", 'y-pos'=>"80" , 'state'=>"success", 'name'=>"Apt4" ,'tag'=>"Temperature:", 'temp'=>"67" ."°"."F", 'status'=>"On" , 'high'=>"85" , 'low'=>"60" , 'location'=>"loc", 'systemID'=>"xxxxxx" ],
['x-pos'=>"700", 'y-pos'=>"80" , 'state'=>"success", 'name'=>"Apt5" ,'tag'=>"Temperature:", 'temp'=>"67" ."°"."F", 'status'=>"On" , 'high'=>"85" , 'low'=>"60" , 'location'=>"loc", 'systemID'=>"xxxxxx" ],
['x-pos'=>"100", 'y-pos'=>"335", 'state'=>"success", 'name'=>"DHW" ,'tag'=>"Temperature:", 'temp'=>"113"."°"."F", 'status'=>"Off", 'high'=>"110", 'low'=>"90" , 'location'=>"loc", 'systemID'=>"xxxxxx" ],
['x-pos'=>"215", 'y-pos'=>"335", 'state'=>"success", 'name'=>"CHW" ,'tag'=>"Temperature:", 'temp'=>"132"."°"."F", 'status'=>"On" , 'high'=>"135", 'low'=>"125", 'location'=>"loc", 'systemID'=>"xxxxxx" ],
['x-pos'=>"390", 'y-pos'=>"270", 'state'=>"warning", 'name'=>"STACK" ,'tag'=>"Temperature:", 'temp'=>"675"."°"."F", 'status'=>"On" , 'high'=>"680", 'low'=>"660", 'location'=>"loc", 'systemID'=>"xxxxxx" ],
['x-pos'=>"700", 'y-pos'=>"250", 'state'=>"warning", 'name'=>"RETURN" ,'tag'=>"Temperature:", 'temp'=>"125"."°"."F", 'status'=>"On" , 'high'=>"135", 'low'=>"110", 'location'=>"loc", 'systemID'=>"xxxxxx" ],
['x-pos'=>"650", 'y-pos'=>"435", 'state'=>"success", 'name'=>"Make-up Water",'tag'=>"Water Amount:",'temp'=>"7" . "gal", 'status'=>"On" , 'high'=>"25" , 'low'=>"10" , 'location'=>"loc", 'systemID'=>"xxxxxx" ],
['x-pos'=>"550", 'y-pos'=>"225", 'state'=>"success", 'name'=>"Steam" ,'tag'=>"Pressure:" , 'temp'=>"12" ." "."lb",'status'=>"On" , 'high'=>"25" , 'low'=>"10" , 'location'=>"loc", 'systemID'=>"xxxxxx" ],
['x-pos'=>"455", 'y-pos'=>"435", 'state'=>"warning", 'name'=>"AQS" ,'tag'=>"Temperature:", 'temp'=>"18" ."°"."F", 'status'=>"On" , 'high'=>"25" , 'low'=>"10" , 'location'=>"loc", 'systemID'=>"xxxxxx" ]
];
return View::make('buildings.furnace', $data);
}
根据命令列和系统id列,我需要分发数据。例如,如果系统_id为60且命令为1,则当前_值为我的apt1的值;如果系统_id为61且命令为1,则当前_值为我的apt2的值,依此类推。我已经做了这么多,似乎我真的不知道下一步该怎么做才能将数据传递给temp。
如果有人能帮我解决这个问题,我将非常高兴。我把它修好了
请访问该网站以获取答案
要显示温度吗?是!根据现在的命令和系统,我对温度进行了硬编码。下一步是建立到数据库的连接并获取数据