原则1.2.3 模型服务
我一直在使用 Codeigniter 和 Doctrine 1.2.3,我想知道是否可以使用自己的服务类(比如在 java ee 和 hibernate 中)。以及如何使这些正确等?
像这样:
class FeedbacktypeService {
public function getFeedbacksByName($value=''){
$q = Doctrine_Query::create()
->from("Feedbacktype f")
->where('f.name LIKE :name', array(':name' => $value));
return $q->execute();
}}
有更好的方法吗? 感谢您的回答和意见。
I have been using Codeigniter with Doctrine 1.2.3 and I am wondering is it possible to use own kind of service classes(like in java ee with hibernate). And how to make those right etc?
Like this:
class FeedbacktypeService {
public function getFeedbacksByName($value=''){
$q = Doctrine_Query::create()
->from("Feedbacktype f")
->where('f.name LIKE :name', array(':name' => $value));
return $q->execute();
}}
Is there better way to do this?
Thanks for your answers and opinions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Doctrine Table 类为对象的所有属性提供动态查找器。如果一个对象“Feedbacktype”有一个属性“name”,你可以这样做:
它不做LIKE匹配,只是相等。它将处理任何属性,甚至 AND 和 OR 属性的组合。
文档位于:http: //www.doctrine-project.org/documentation/manual/1_0/en/dql-doctrine-query-language:magic-finders
Doctrine Table classes provide dynamic finders for all properties on an object. If an object "Feedbacktype" has a property "name", you can do:
It doesn't do LIKE matching, just equality. It will handle any property, and even combinations of AND and OR properties.
The docs are here: http://www.doctrine-project.org/documentation/manual/1_0/en/dql-doctrine-query-language:magic-finders