我对此查询感到困惑,请告诉我如何将此查询转换为codeigniter活动记录方法
select * from view_log where user_id=XXXX and date(time) = curdate();
这里的时间是一个时间戳记,因此我想从中提取日期并将其与今天的日期进行比较。我尝试使用
set
,但是它不起作用,即使将其作为string
传递也不起作用。 最佳答案
尝试这个
$this->db->select('*');
$this->db->from('view_log');
$this->db->where('user_id=XXXX and date(time) = curdate()');
$result=$this->db->get();
或最简单的方法
$this->db->select('*');
$this->db->from('view_log');
$this->db->where('user_id','XXX');
$this->db->where('DATE(time)', 'CURDATE()', FALSE);
$result=$this->db->get();
关于mysql - 在Codeigniter事件记录方法中使用MySQL函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17189233/