简体   繁体   English

"Prod 上 cakephp 的 querybuilder 的内部错误"

[英]interal error with querybuilder of cakephp on Prod

I'm working under wamp with php 7.4.26 @windows.我正在使用 php 7.4.26 @windows 在 wamp 下工作。 I have a project under cakephp.我在 cakephp 下有一个项目。 It works well on Dev Environnement.它在开发环境中运行良好。

However when I upload the code on PROD (linux\/ PHP 7.4), it gives me an internal error (500).但是,当我在 PROD (linux\/PHP 7.4) 上上传代码时,它给了我一个内部错误 (500)。 I know what's wrong, but I don't know why this happens only on linux.我知道出了什么问题,但我不知道为什么这只发生在 linux 上。

$users = TableRegistry::getTableLocator()->get('users');
$user = $users->find('all')->contain(['Products' => ['sort' => ['Products.id' => 'DESC']]])->first();

SELECT 
products.id AS `products__id`, 
products.name AS `products__name`

FROM products products 
ORDER BY Products.id DESC -- Products vs products!!

This seems not to be php related, but more likely coming from the SQL engine you use which is different under the WAMP context and the linux server.这似乎与 php 无关,但更有可能来自您使用的 SQL 引擎,它在 WAMP 上下文和 linux 服务器下是不同的。 WAMP lets the user choose between MariaDB and MySQL, and it seems you don't mention which database engine is used on the linux side. WAMP 允许用户在 MariaDB 和 MySQL 之间进行选择,而且您似乎没有提到在 linux 端使用哪个数据库引擎。

The fact is that either MySQL or MariaDB are said, according to a quick search, to be case insensitive on table names.事实是,根据快速搜索,MySQL 或 MariaDB 都被称为对表名不区分大小写。 So, i think you should at first glance try to get the information about which SQL engine is used on the linux server, and then try to change the collation used for storing the table names.因此,我认为您应该首先尝试获取有关在 linux 服务器上使用哪个 SQL 引擎的信息,然后尝试更改用于存储表名的排序规则。 If you cannot change it, you will have to adapt your code to it.如果你不能改变它,你将不得不调整你的代码来适应它。

But at last, since relying on case sensitivity can be source of errors, relying on case insensitivity can also be source of errors, at your place I would avoid both.但最后,由于依赖大小写敏感可能是错误的来源,依赖不区分大小写也可能是错误的来源,在你的位置我会避免两者。

"

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

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