我必须在我的代码中使用以下条件,但只有条件01和03正常工作。有人可以帮我吗?我的代码是:
public function errorTime(){
$fromDate=date("Y-m-d", strtotime($_SESSION['FromDate']));
$toDate=date("Y-m-d", strtotime($_SESSION['ToDate']));
$this->db->select('*');
条件01
$where = "(TimeStatus='Yes' AND CheckIn='00:00:00' OR TimeStatus='Yes' AND CheckOut='00:00:00')";
$this->db->where($where);
条件#02
$this->db->where('TotalTime <', 0);
条件#03
$this->db->where('Date >=', $fromDate);
$this->db->where('Date <=', $toDate);
$this->db->from('tb_time');
$query=$this->db->get();
return $query->num_rows();
}
注意:TotalTime - &gt;数据类型:Float
答案 0 :(得分:0)
最后,我找到了解决方案:
public function errorTime(){
$fromDate = date("Y-m-d", strtotime($_SESSION['FromDate']));
$toDate = date("Y-m-d", strtotime($_SESSION['ToDate']));
$this->db->select('*');
$where = "(TimeStatus='Yes' AND CheckIn='00:00:00' OR TimeStatus='Yes' AND CheckOut='00:00:00' OR CheckOut <= CheckIn)";
$this->db->where($where);
$this->db->where('Date >=', $fromDate);
$this->db->where('Date <=', $toDate);
$this->db->from('tb_time');
$query=$this->db->get();
return $num_rows=$query->num_rows();
}