简体   繁体   English

相同的查询不同的结果

[英]Same query different results

I have checked lots of other questions with the same or similar title, and they do not have an answer that is working for my issue:我检查了许多具有相同或相似标题的其他问题,但他们没有适合我的问题的答案:

// Query:

SELECT *
FROM `rbs`
WHERE `rbs_id` = '92448'

// Simplified output from PHP script

[rbs_id] => 92448
[rbs_status] => 4
[start_date] => 2022-07-22 13:58:36
[end_date] => 2022-07-22 15:12:24

When I run that exact same query on phpMyAdmin AND MySQL command line, I get the following result:当我在 phpMyAdmin 和 MySQL 命令行上运行完全相同的查询时,我得到以下结果:

[rbs_id] => 92448
[rbs_status] => 4
[start_date] => 2022-07-22 13:58:36
[end_date] => 2022-12-31 23:59:59

So - two of the three ways to run the query return the end date as the end of this year, which is what I am expecting to see, but in PHP, it uses the current date as the end_date (Refreshing the page updates the end_date in the result, as if something is updating the result AFTER the query with the expected date, but there is nothing that does that:所以 - 运行查询的三种方式中的两种将结束日期返回为今年年底,这是我期望看到的,但在 PHP 中,它使用当前日期作为end_date (刷新页面会更新end_date在结果中,好像某些东西在使用预期日期的查询之后更新了结果,但是没有什么可以做到这一点:

$query = $this->db->get($this->table);
print_r($this->db->last_query());
print_r($query->row_array());

I am using Codeigniter 3.1.11 query builder to construct the query, then I output the query that it generated, and copied and pasted that to phpMyAdmin and MySQL command line, so the query is the same in all cases, and it is a very simple query as you can see. I am using Codeigniter 3.1.11 query builder to construct the query, then I output the query that it generated, and copied and pasted that to phpMyAdmin and MySQL command line, so the query is the same in all cases, and it is a very如您所见,简单的查询。

I have restarted the MySQL server, for good measure, but not fixing the issue.我已经重新启动了 MySQL 服务器,但没有解决问题。

And yes, for stating the obvious - I am using the same database in the PHP script, phpMyAdmin as well as in MySQL.是的,为了说明这一点 - 我在 PHP 脚本、phpMyAdmin 以及 MySQL 中使用相同的数据库。

Any ideas what could cause the difference in results?有什么想法会导致结果不同吗?

It's timezone issue I think You just have to check timezone of your system as well as from script.这是时区问题,我认为您只需要检查系统的时区以及脚本即可。 If both times are different then there's a problem如果两个时间不同,那就有问题了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM