我有一个查询来获取员工的日程安排并将其显示在表格中。我使用默认计划对一些员工进行了抽样,但是当我尝试检索具有不同计划的其他员工时,它总是返回false,表示该表为空。这是我的查询:
function get_Sked($id,$from,$to)
{
$query = "SELECT c.dt, a.TimeFrom,a.TimeTo FROM schedule a LEFT JOIN cal c ON a.SkedDate = c.dt AND a.EmpID = ? WHERE c.dt BETWEEN DATE(?) AND DATE(?) GROUP BY c.dt ORDER BY c.dt ASC";
$query = $this->db->query($query,array($id,$from,$to));
if($query->num_rows() == 0)
{
return false;
}
else
{
return $query->result_array();
}
}
这是调用它的方法:
$data['sked'] = $this->DBmodel->get_Sked($id,$dFrom,$dTo);
if($data['sked'] == false)
{
echo "Default Schedule of 8:00 am to 5:00 pm."; //if table is empty show default sched.
var_dump($data['sked']);
}
else
{
foreach($data['sked'] as $val) //this will show the content of the table.
我使用与其他查询序列相同的查询序列,并且只有这个问题没有问题.....
我将查询结构更改为:
$this->db->select('c.dt,a.TimeFrom,a.TimeTo');
$this->db->from('cal c');
$this->db->join('schedule a','a.SkedDate = c.dt');
$this->db->where('a.EmpID',$id);
$this->db->where('c.dt',$from);
$this->db->where('c.dt',$to);
$query = $this->db->get();
但仍然返回false ....