我被这个查询卡住了,请告诉我如何将这个查询转换成 codeigniter 事件记录方法
select * from view_log where user_id=XXXX and date(time) = curdate();
其中 time 是时间戳,所以我想从中提取日期并将其与今天的日期进行比较。我尝试使用 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/