生成的 Doctrine 模型尊重大小写,但生成的 Yaml 不尊重大小写

发布于 2024-08-10 08:27:13 字数 629 浏览 1 评论 0原文

刚刚开始使用 Doctrine ORM for PHP (v1.1.5) 并遇到了一些意想不到的事情。

我使用以下方法从数据库(MySQL 4)生成模型:

Doctrine::generateModelsFromDb($pathToModels);

然后使用以下方法从模型生成 YAML:

Doctrine::generateYamlFromModels($pathToSchema . '/schema.yml', $pathToModels);

在生成的模型中,列名称(如 hasColumn() 中定义)使用相同的大小写与数据库中的字段一样。一切都好。

但在生成的 YAML 中,无论模型中的大小写如何,列名称都是小写的。

generateYamlFromModels() 方法上似乎没有任何可用的选项,我可以用它来调整它。我是否应该在某个地方设置一些其他属性,也许是在连接级别,或者在管理器级别等?这可能是一个错误吗?

任何想法都非常感激。谢谢并欢呼!

Just getting started with Doctrine ORM for PHP (v1.1.5) and ran into something unexpected.

I am generating models from the db (MySQL 4) using:

Doctrine::generateModelsFromDb($pathToModels);

Then generating YAML from the models using:

Doctrine::generateYamlFromModels($pathToSchema . '/schema.yml', $pathToModels);

In the generated models, the column names (as defined in hasColumn()) use the same case for the fields as in the db. All good.

But in the generated YAML, the column names are all lower-case, irrespective of the case in the model.

There do not seem to be any options available on the generateYamlFromModels() method that I could conceivably use to tweak this. Is there some other attribute I should be setting someplace, perhaps at connection-level, or at manager-level, etc? Might it be a bug?

Any ideas greatly appreciated. Thanks and cheers!

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

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

发布评论

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

评论(1

摘星┃星的人 2024-08-17 08:27:13

看来这是一个错误。我这么说是因为 YAML 区分大小写,而 Doctrine 的 generateYAMLFromModels() 记录到区分大小写。我确实发现了 2.0 测试版中的一个 区分大小写错误。也许这是影响您的程序的错误。不过,除非有其他问题,看起来 Dimitris Baltas 的评论似乎是首选的解决方法:

另一种替代方法是从数据库生成模型,然后从模型生成 yaml。这个保留了正确的外壳。

狩猎快乐:)

It seems this is a bug. I say that because YAML is case sensitive, and Doctrine's generateYAMLFromModels() is documented to be case sensitive. I did find a case sensitivity bug that was in 2.0 beta. Maybe this is the bug that affected your program. Barring anything else, though, it looks like Dimitris Baltas' comment seems to be the the workaround of choice:

an other alternative is to generate models from DB and then yaml from models. This one keeps the right casing.

Happy Hunting :)

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