0
votes

I've been using Doctrine since about 2007. I recently picked up Symfony2, which includes Doctrine 2, and from my perspective, Doctrine 2 is significantly worse than Doctrine 1.

One thing that seems particularly dumb is that I have to do something like this just to retrieve a certain record:

$em->getRepository('VNNPressboxBundle:School')->find($id);

In Doctrine 1, I believe I would have done something like this:

Doctrine::getTable('School')->find($id);

The verbosity is not what bothers me. The problem is that any place I want to do anything to do with the database, I have to have an $em available. This means I have to have a ton of methods like this:

public function foo($em, $something, $somethingElse)
{
}

public function bar($em, $thing)
{
}

public function baz($whatever, $whateverElse)
{
}

It feels wrong to drag these $em instances around. It's also irrelevant to what the method really does. Further, I have to remember, every time I call a method, "Does this method need an $em or not?" It's totally lame. I want to know if I'm doing this wrong or if this is just the way they want you to use it. It certainly feels wrong.

Unfortunately, what I've read of the Doctrine docs seems to be heavy on practice and light on theory. Where can I find some good documentation on the design decisions behind Doctrine 2?

1
Jason, you can do a sigle class based on Singleton Pattern in order tu call your doctrine 2 functions like MyDoctrine::EM->find('VNNPressboxBundle:School', $id); - manix
My initial reaction is that that seems like a good idea. I wonder why they didn't just build that into the tool. - Jason Swett

1 Answers

0
votes

It seems like if you want to understand Doctrine 2, it helps to understand a little bit about Service-Oriented Architecture and Dependency Injection.