是否可以让 Doctrine 1.2.2 生成 getter 和 setter?

发布于 2024-09-14 08:54:00 字数 107 浏览 4 评论 0原文

我正在寻找一种方法让 Doctrine 为我生成 getter 和 setter,否则它会调用 Doctrine_Record “get”方法,这会花费大量时间。

那么有机会这样做吗?

I'm looking for a way to let Doctrine generate getters and setters for me, because otherwise it will call the Doctrine_Record "get" method which costs a lot of time.

so is there a chance to do that?

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

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

发布评论

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

评论(2

岁月流歌 2024-09-21 08:54:00

这不是 Doctrine 的工作原理,正如 kuba 所写,该功能已从 Doctrine 中删除(这样做是有原因的)。当前的稳定版本严重依赖魔法功能。像 Doctrine 那样通过魔法 getter 和 setter 访问字段并不需要花费太多时间。学说的其他部分需要花费更多时间。因此,如果您的学说存在性能问题,您应该通过使用数组结果进行查询(即 fetchArray 而不是执行)来“解决”该“问题”。这节省了大量的时间和内存。如果您需要对象,您可以根据需要将数组数据合并为对象。

getter 和 setter 的创建是某种微优化,可能会给您带来很多麻烦。如果我是你,我会继续遵循教义的标准方式。

That's not how Doctrine works and as kuba wrote the feature was removed from Doctrine (there were reasons to do so). The current stable version relies heavily on magic functions. Accessing the fields via the magic getters and setter like Doctrine is doing it does not cost that much time. There are other parts of doctrine that are much more time consuming. So if you have performance issues with doctrine you should "attack" that "problem" by using array results for your query (i.e. fetchArray instead of execute). That's saving a lot of time and memory. If you need objects you can hydrate the array data to an object as needed.

The creation of getter and setter is some kind of micro-optimization that will may cause you a lot of trouble. If I were you I would keep going the standard way of Doctrine.

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