检索关联数据时出错。仅Linux [英] Error when retrieving associated data on. Linux only

查看:72
本文介绍了检索关联数据时出错。仅Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此问题之前,我有另一个与同一主题相关的问题。由于ta @ndm,该问题已得到解决。

Prior this problem I had another issue related to the same subject. The problem has been sorted thanks ta @ndm.

链接上一个问题: Cakephp 3. Windows和Linux操作系统在以下情况下返回不同的结果查询数据库

我有一个文章页面,并且正在检索与文章相关的数据。文章评论。

I have an article page and I am retrieving the associated data with articles. Article comments.

我有以下代码行

$this->Articles->find()->contain('ArticleComments');

本地Windows 10机器和生产Debian服务器上的这一行代码都检索所有文章,包括其评论。使用Cakephp调试功能 pr($ object)

This line of code on both local Windows 10 machine and production Debian server retrieves all articles including their comment. find a link to a screenshot of the returned result using Cakephp debugging function pr($object)

返回结果的屏幕快照: http://s29.postimg.org/f76brygw6/cakephp.jpg

Screenshot of the returned result: http://s29.postimg.org/f76brygw6/cakephp.jpg

现在,我唯一遇到的问题(仅在生产Debian服务器上出现)是,尽管上述代码返回了文章和文章注释,但我无法使用此对象。例如,如果我尝试以下代码:

Now the only problem I have, which occurs only on the production Debian server is that despite the aforementioned line of code is returning articles and article comments I cannot use this object. For an instance if I try the following code:

$this->Articles->find()->contain('ArticleComments')->toArray();

$this->set('articles', $this->Articles->find()->contain('ArticleComments'));

我收到此错误:


无法将值转换为整数
InvalidArgumentException

Cannot convert value to integer InvalidArgumentException

tmp / error.log中的以下错误: http://s14.postimg.org/4e88qp6j4/cakephp_error.jpg

And the following error in tmp/error.log: http://s14.postimg.org/4e88qp6j4/cakephp_error.jpg

同样,此错误仅在我的Debian服务器上发生,并且如果我仅通过以下代码检索文章,它就可以正常工作。

Again, this error occurs only on my Debian server and if I retrieve just articles by the following code it works fine.

$this->Articles->find()

我为解决此问题所做的工作:

What I have done to fix this issue:


  1. 对表名和类名进行三重检查(两次)。 100%确保问题不是文件命名。

  2. 检查了机器的PHP和Cakephp版本。我的Debian服务器运行PHP 5.6.15-1〜dotdeb + zts + 7.1(cli),而Windows 10运行PHP 5.6.8(cli)。 Cakephp版本相同。 Cakephp 3.1.4


推荐答案

问题已解决!

问题不是来自Linux或CakePHP。

The issue was not coming from Linux nor CakePHP.

在我的本地计算机上(恰好是Windows操作系统)我正在运行MySQL版本5.6.24,并在运行Linux debian的实时服务器上安装了MySQL 5.5.46。

On my local machine which happens to be Windows OS I am running MySQL version 5.6.24 and on my live server, which runs Linux debian I have MySQL 5.5.46.

我有数据库列 datetime,该列在5.6中受支持,但在5.5版中引起了问题。

I had database columns "datetime" which is supported in 5.6 but was causing a problem in version 5.5.

我只是将列类型更改为时间戳,问题就解决了。

I simply changed the column type to "timestamp" and the issue was resolved.

两个环境都运行不同的操作系统,因此花费了大量时间来确保问题不是Windows到Linux的问题(即文件名区分大小写)。 CakePHP误导性的错误消息也使我也无法解决问题。

Both environments are running different OS's and an enormous amount of time was spent to ensure the issue is not Windows to Linux problem(i.e. filename case sensitivity). CakePHP misleading error messages has delay me to resolve the problem also.

一个多月后,我很高兴问题已解决:D

I am glad after more than a month the problem is fixed :D

这篇关于检索关联数据时出错。仅Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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