date() function as first parameter of CodeIgniter's where() call causes query failure
I'm not able to fetch data from my CodeIgniter model method implementing query builder calls. I don't know where I am going wrong.
public function downloadOrderDailyReport()
{
//$this->load->helper('date');
$timestamp = date("Y-m-d");
$this->db->select("O.created, O.paymentMethod,B.SKU as sku, B.name as Bname, B.author as authors, B.edition,B.MRP as mrp, OD.status as order_status");
$this->db->from("orders AS O");
$this->db->join("users AS U", 'O.userid=U.id');
$this->db->join("orderDetail AS OD","O.parentId=OD.orderId", 'LEFT');
$this->db->join("books AS B","OD.bookId=B.id", 'LEFT');
$this->db->where("O.parentId !=", NULL);
$this->db->where(date('O.created'), $timestamp);
$query = $this->db->get();
return $orders = $query && $query->num_rows() ? $query->result() : [];
}
My created column date format is like 2018-02-06 14:29:02.
I need to compare only today's date not time. When I remove the second where() call, the method works fine (doesn't break).