2015-02-24 109 views
0

由于某种原因,当我通过Date_Scheduled desc进行订购时,它仍然会首先保留最早的日期。我正在尝试获取它,以便最新的日期显示最后一个最早的日期。不知道我是否正确地写这篇文章。我在codeigniter中遇到了我的订单问题

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

<?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); 

    } 
} 
+0

这是一个延伸,但date_scheduled的数据类型是什么? – Xedni 2015-02-24 16:44:44

+0

它是navchar(50)会是我的日期在该字段中回显的问题 – Veronica 2015-02-24 17:01:20

+0

我需要它,因此用户可以更改日期 – Veronica 2015-02-24 17:02:22

回答

0

这个答案解决您的问题的一部分,因为你必须处理好与正确的列类型date而不是varchar日期。

如果查询结果总是返回ORDER BY ASC,则可以翻转该数组。

array_reverse($this->Employee_model->get_employee()); 
+0

我会在哪里放置我的模型或控制器? – Veronica 2015-02-24 19:23:43

+0

这是我现在的坚持者\t $ data ['employee'] = $ this-> employee_model-> get_employee(); – Veronica 2015-02-24 19:29:45

+0

也用MSSQL做这个工作吗? – Veronica 2015-02-24 19:30:38