开发者

doctrine 1.2.3 service for model

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.


Doctrine Table classes provide dynamic finders for all properties on an object. If an object "Feedbacktype" has a property "name", you can do:

return Doctrine::getTable('Feedbacktype')->findByName($value);

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜