Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用CodeIgniter框架。如何获取结果,但将结果限制在过去12小时内?_Php_Mysql_Codeigniter_Timestamp_Between - Fatal编程技术网

Php 使用CodeIgniter框架。如何获取结果,但将结果限制在过去12小时内?

Php 使用CodeIgniter框架。如何获取结果,但将结果限制在过去12小时内?,php,mysql,codeigniter,timestamp,between,Php,Mysql,Codeigniter,Timestamp,Between,基本上,我有一个完整的数据库表专门用于用户提交。每一行都有一列timestamp,它是用户提交时的phptime(),还有一列username,我使用它将表过滤为一个特定的用户名 但是用户名有多行(比如超过9000行) 我怎样才能将其过滤到仅仅过去的12小时?这是43200秒 我如何才能有效地做到这一点 我似乎找不到一个CodeIgniterdb query函数,它可以通过在now和now-43200之间限制结果 我必须注意,timestamp字段的类型是BIGINT(20),它存储一个PHP时

基本上,我有一个完整的数据库表专门用于用户提交。每一行都有一列
timestamp
,它是用户提交时的php
time()
,还有一列
username
,我使用它将表过滤为一个特定的用户名

但是用户名有多行(比如超过9000行)

我怎样才能将其过滤到仅仅过去的12小时?这是
43200秒

我如何才能有效地做到这一点

我似乎找不到一个CodeIgniter
db query
函数,它可以通过
now
now-43200之间限制结果

我必须注意,
timestamp
字段的类型是
BIGINT(20)
,它存储一个PHP时间戳
time()

用于下面的查询

SELECT * FROM reports WHERE username = "username" and `Date` > NOW() - INTERVAL 12 HOUR
内码点火器

$this->db->query("SELECT * FROM reports WHERE username = "username" and `Date` > NOW() - INTERVAL 12 HOUR")->result_array();
使用下面的查询

SELECT * FROM reports WHERE username = "username" and `Date` > NOW() - INTERVAL 12 HOUR
内码点火器

$this->db->query("SELECT * FROM reports WHERE username = "username" and `Date` > NOW() - INTERVAL 12 HOUR")->result_array();

只需使用where子句
where(“timestamp\u column只需使用where子句
where”(“timestamp\u column”您可以向我们显示您的查询吗?到目前为止您尝试了什么?@FMashiro-目前是
$query=$this->db->get\u where('reports',array('username'=>$username))
但不确定有效地将结果限制在过去的
43200秒的最佳方式
您能告诉我们您的查询吗?到目前为止您尝试了什么?@FMashiro-目前是
$query=$this->db->get_where('reports',array('username'=>username));
但不确定有效地将结果限制在过去的
43200秒的最佳方式是不是应该是
=