tags:

views:

8

answers:

1

in some tutorials they tell you to set up an attribute like this:

$manager = Doctrine_Manager::getInstance();
Doctrine_Manager::getInstance()->setAttribute(
    Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);

and in the documentation it shows you this:

$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(
    Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);

i wonder which one i should use? isn't it the latter one? cause how can you set an attribute to a singleton class in the first one? isn't the second one more correct?

A: 

Do you even understand the code you're looking at?

The first code is "wrong". First it assigns Doctrine_Manager object $managger, and then this variable is not used.

If you want to do more than one thing on Doctrine_Manager then it's natural to get assign this reference to something that won't mess up your code. If you want to do just one thing there is no need to use extra variable, in other words:

Doctrine_Manger::getInstance()->setAttribte(...);

or

$manager = Doctrine_Manger::getInstance();
$manager->setAttribute(...);
$manager->setAttribute(...);
$manager->doSth();
$manager->blahblahblah();
Crozin