记录小于15分钟的活动记录 [英] Active record where record is less than 15 minutes old

查看:120
本文介绍了记录小于15分钟的活动记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Codeingiter的活动记录,需要检查小于15分钟的条目。

I am using Codeingiter's active record and need to check for entries that are less than 15 minutes old.

我已经尝试过以下,我认为会工作。

I have tried the following, which I thought would work.

$this->EE->db->select('entry_id')
             ->from('exp_channel_titles')
             ->where('status', $status)
             ->where('channel_id', $channel)
             ->where(FROM_UNIXTIME('entry_date') >= DATE_SUB(CURDATE(), INTERVAL 15 MINUTE))
             ->order_by('entry_date', 'desc'); 

有没有人知道是否可以这样做?

Does anyone know if its possible to do this?

我希望这会在where子句中执行。

I had hoped this would do work in a where clause"

FROM_UNIXTIME('entry_date') >= DATE_SUB(CURDATE(), INTERVAL 15 MINUTE)


推荐答案

a href =https://ellislab.com/codeigniter/user-guide/database/active_record.html =nofollow> https://ellislab.com/codeigniter/user-guide/database/active_record.html :

From https://ellislab.com/codeigniter/user-guide/database/active_record.html:

$ this-> db-> where()接受一个可选的第三个参数如果你设置
到FALSE,CodeIgniter不会尝试保护您的字段或表
名称与反引号。

$this->db->where() accepts an optional third parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks.

$ this-> db-> where('MATCH AGAINST(value)',NULL,FALSE);

$this->db->where('MATCH (field) AGAINST ("value")', NULL, FALSE);

所以你应该能够传递一个字符串:

So you should be able to pass a string like:

 ->where('FROM_UNIXTIME(`entry_date`) >= DATE_SUB(CURDATE(), INTERVAL 15 MINUTE)', NULL, FALSE)

这篇关于记录小于15分钟的活动记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆