代码点火器 +原则:控制器中的 CRUD?
我是 MVC、CodeIgniter 和 Doctrine 的新手,所以也许我的问题不太相关。如果是这样的话请原谅我。
我一直在阅读 PHPandStuff.com。我真的很喜欢我所看到的 Doctrine,并希望将其用于我的项目。但是,由于所有与数据库相关的操作都应该保存在 Model 中而不是 Controller 中,那么使用 Doctrine 的 CRUD 操作是否也应该放置在 Doctrine Model 中呢?如果是这样,那又如何呢?
提前致谢
I am a newbie to MVC, CodeIgniter and Doctrine, so maybe my question is not that relevant. Pardon me if thats the case.
I've been reading the CodeIgniter + Doctrine tutorials on PHPandStuff.com. I really like whatever I have seen of Doctrine and wish to use it for my project. However, since all database related operations should be kept in the Model and not the Controller, shouldnt the CRUD operations which use Doctrine also be loacted in the Doctrine Model instead? If so, then how?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不想将 DQL 写入控制器(这是一件好事),您可以将单独的函数放入模型中,仅使用扩展类提供的功能。
例如,如果您有一个名为
User
的类,并且需要保存它,您可以简单地执行以下操作,这样您就可以按照您的需要在模型中拥有所有函数。
If you don't want to write the DQL into the Controller (which is a good thing) you can put separate functions into your model that just work with the functionality provided by the extended classes.
For example, if you have a class called
User
, and you need to save it, you simple could doSo you have all functions inside the model just as you wanted it.