Magento数据库连接问题

发布于 2024-10-19 15:06:03 字数 1568 浏览 2 评论 0原文

我正在开发 Magento Enterprise v1.9.0.0。 我需要连接到数据库并直接运行 SQL 来查询表。

这就是我曾经这样做过的。

    $query = "...SQL QUERY...";
    $databaseConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
    $result = $databaseConnection->fetchAll($query);

我的本地计算机上安装了 Magento Community v1.4.1.1 和 Magento Enterprise v1.9.0.0。 因此,为了进行测试,我在本地计算机上运行了上述代码,一切正常。

但它不适用于实时服务器。 Magento Enterprise v1.9.0.0 已安装在实时服务器上,并且在线商店正在运行。 现场商店一切正常,没有什么特别的事情发生。

但是我把这段代码上传到服务器了,还是不行。 此外,我无法收到任何 PHP/MySQL 错误消息。

这是我用来跟踪运行时间的更详细的代码。

    // Debug Output
    $this->OutputDebugLogo("<br/>");
    $this->OutputDebugLogo("<br/><h3>Query : </h3>#", $query);

    $databaseConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
    $result = $databaseConnection->fetchAll($query);

    // Debug Output
    $this->OutputDebugLogo("<br/><h3>Result : </h3>#", $result);
    $this->OutputDebugLogo("<br/>");

我可以确定SQL语句没有错误。 函数OutputDebugLogo()是我自己编写的,用于输出带有变量的调试消息。

这是我在本地计算机上运行此脚本后得到的结果。

    Query :
    ' SELECT ... FROM ... WHERE ... '

    Result:
    array ( 0 => array ( 'items' => 'a:2:{s:3:"MEN";a:11:{s:9:... )

在这里你可以看到我在实时服务器上拥有的内容。

    Query :
    ' SELECT ... FROM ... WHERE ... '

如您所见,没有 PHP/MySQL 错误消息。 我们可以说脚本在数据库代码块处停止运行。

我无法取得任何进展来寻找主要原因。 为什么会发生这样的事? 有人能知道吗?

我真的很期待得到大家的帮助。

此致。 软盘

I'm working on Magento Enterprise v1.9.0.0.
I need to connect to the database and run SQL directly to query tables.

Here is what I've used to do that.

    $query = "...SQL QUERY...";
    $databaseConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
    $result = $databaseConnection->fetchAll($query);

I have Magento Community v1.4.1.1 and Magento Enterprise v1.9.0.0 installed on my local computer.
So in order to test, I've run the above code on my local machine, and all works fine.

But it doesn't work on live server.
Magento Enterprise v1.9.0.0 is installed on the live server and online store is running.
All works fine on live store and nothing special happens.

But I've uploaded this code to the server, it doesn't work.
And further, I can't get any PHP/MySQL error message.

Here is more detailed codes which I used to track run time.

    // Debug Output
    $this->OutputDebugLogo("<br/>");
    $this->OutputDebugLogo("<br/><h3>Query : </h3>#", $query);

    $databaseConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
    $result = $databaseConnection->fetchAll($query);

    // Debug Output
    $this->OutputDebugLogo("<br/><h3>Result : </h3>#", $result);
    $this->OutputDebugLogo("<br/>");

I can be sure there is no error on SQL statement.
And the function OutputDebugLogo() is made by myself to output debug message with variables.

Here is what I've got after running this script on my local machine.

    Query :
    ' SELECT ... FROM ... WHERE ... '

    Result:
    array ( 0 => array ( 'items' => 'a:2:{s:3:"MEN";a:11:{s:9:... )

And here you can see what I've got on the live server.

    Query :
    ' SELECT ... FROM ... WHERE ... '

As you can see, there is no PHP/MySQL error message.
And we can say the script wass stopped running at database code block.

I can't make any progress to find the main cause.
Why did it happen?
Can anyone know it?

I'm really looking forward to getting help from everyone.

Best Regards.
Floppy

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

给妤﹃绝世温柔 2024-10-26 15:06:03

我在 Magento Enterprise 1.9.0.0 上运行了你的脚本,它运行没有任何问题,因此脚本本身似乎没有任何问题。您的查询是什么?您没有考虑到两个版本之间可能存在架构差异。

希望有帮助!

谢谢,

I ran your script on Magento Enterprise 1.9.0.0 and it worked with no problems, so there doesn't appear to be any problem with the script itself. what is your query? It's likely that there is a schema difference between the two versions that you aren't taking into account.

Hope that helps!

Thanks,
Joe

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文