0
我有以下代碼爲每個MAC獲取一條線與最新狀態。我遇到的問題是我得到一條線,但不是最新的狀態,而是最早的。代碼點火器 - 沒有顯示我需要的條目
function get_active_devices($min_duration, $max_duration)
{
//get all active devices DESC order
$this->db->distinct();
$this->db->group_by('mac');
$this->db->order_by("id", "desc");
$this->db->select('data.mac, state, time, iot_bo.notified, iot_bo.op_state, iot_bo.Name');
$this->db->where('time >', time()-$max_duration);
$this->db->where('time <', time()-$min_duration);
$this->db->join('iot_bo', 'iot_bo.mac = data.mac');
$this->db->where('iot_bo.op_state', '1');
$query = $this->db->get();
return $query;
}
是的,我已經嘗試過了,它恢復了正確的結果 – Simon