我在codeigniter中遇到了订单问题

时间:2015-02-24 16:37:55

标签: php sql-server codeigniter

出于某种原因,当我通过Date_Scheduled desc进行订购时,它仍然是最早的日期。我试图得到它,以便最新的日期显示最后和最早的日期。我不确定我写的是否正确。

这是我的模型,它是获取员工的职能。

<?php

class Employee_model extends CI_Model 
{

    public function insert_employee($data)
    {
    $this->db->insert('employee_list',$data); 
return $this->db->insert_id(); 
    }
    public function get_employee()
    {
        $this->db->select('*');
        $this->db->from('employee_list');
        $this->db->where('status',1);
        $this->db->order_by ("Date_Scheduled", "desc"); 
        $this->db->order_by("Scheduled_Area", "desc");
        $this->db->order_by("Time_Reported", "desc");  




        $query =$this->db->get();
        return $query->result();
    }
    public function delete_employee($id,$data)
    {
        $this->db->where('id',$id);
        $this->db->update('employee_list',$data);
            return print_r($data);


    }
    public function edit_employee($id)
    {
        $this->db->select('*');
        $this->db->from('employee_list');
        $this->db->where('id',$id);
        $this->db->where('status',1);
        $query =$this->db->get();
        return $query->result();

    }
    public function update_employee($data,$id)
    {
        $this->db->where('id',$id);
        $this->db->update('employee_list',$data);
        return print_r($data);

    }
}

1 个答案:

答案 0 :(得分:0)

此答案解决了部分问题,因为您应该使用正确的列类型date处理日期而不是varchar

如果查询结果始终返回ORDER BY ASC,则可以翻转数组。

array_reverse($this->Employee_model->get_employee());
相关问题