gpt4 book ai didi

mysql - 在 codeigniter 事件记录方法中使用 MySQL 函数

转载 作者:行者123 更新时间:2023-12-01 00:49:57 25 4
gpt4 key购买 nike

我被这个查询卡住了,请告诉我如何将这个查询转换成 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com