根据日期从数据库中获取数据

问题描述 投票:0回答:1

这是我的表字段table1:cash_transactions id dated_on amount from_user to_user trans_type userid purpose table2:login loginid name username password usertype status

控制器:管理员

public function daily_report()
{
    $daily_date=date('Y-m-d');
    $data['fetch']= $this->admin->get_daily_report($daily_date);
    $this->load->view('daily_report',$data);

}

型号:Admin_Model

public function get_daily_report($daily_date)
{
    $this->db->select('c.userid,c.amount,c.trans_type,c.from_user,c.to_user,c.purpose,l.loginid,l.name');
    $this->db->from('cash_transactions as c');
    $this->db->join('login as l', 'c.userid = l.loginid');
    $this->db->where('c.dated_on',$daily_date);
    $query = $this->db->get();
    $result =$query->result();
    return $result;
}

这里我想从数据库中获取当前日期数据,但这不起作用。请解决这个问题。

codeigniter
1个回答
0
投票

你可以试试这个:

控制器:管理员

public function daily_report()
{
    $daily_date=date('Y-m-d');
    $data['fetch']= $this->admin->get_daily_report($daily_date);
    $this->load->view('daily_report',$data);

}

型号:Admin_Model

public function get_daily_report($daily_date)
{
    $this->db->select('c.userid,c.dated_on,c.amount,c.trans_type,c.from_user,c.to_user,c.purpose,l.loginid,l.name');
    $this->db->from('cash_transactions as c');
    $this->db->join('login as l', 'c.userid = l.loginid');
    $this->db->where('c.dated_on',$daily_date);
    $query = $this->db->get();
    $result =$query->result();
    return $result;
}
© www.soinside.com 2019 - 2024. All rights reserved.