0

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.

user257980
  • 1,059
  • 2
  • 15
  • 31

1 Answers1

1

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

dbellizzi
  • 713
  • 8
  • 18