0

这里 Date 的格式为 yy-mm-dd hr:min:sec 其中 $this->get('on') 的格式为 yy-mm-dd 。那么现在如何比较这两个值呢?

function customer_get()
{
        $this->db->select('user_id,first_name,last_name,email');
        $this->db->from('customers');
        $this->db->join('orders', 'user_id = customer_user_id','inner');
        $array = array('Date' => $this->get('on'));
        $this->db->where($array);
        $query = $this->db->get();
        if($query)
        {
                $this->response($query->result(),200);
        }
        else
        {
                $this->response(NULL, 404);
        }
}
4

1 回答 1

0

啊,您需要为查询正确格式化日期:

function customer_get()
{

        $this->db->select('user_id,first_name,last_name,email');
        $this->db->from('customers');
        $this->db->join('orders', 'user_id = customer_user_id','inner');
        $this->db->where('DATE(`Date`)', $this->get('on'), false);
        $query = $this->db->get();
        if($query)
        {
                $this->response($query->result(),200);
        }
        else
        {
                $this->response(NULL, 404);
        }

}
于 2013-06-10T16:27:19.000 回答