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
精彩评论