Take the 2-minute tour ×

I have a class:

class  Square_Utility_Doctrine {
    protected static $entityManager;

    public function __construct()
        self::$entityManager = $bootstrap->getResource('doctrine');

    public static function getEntityManager()
        return self::$entityManager;

When I use the functio getEntityManager() like:

$this->entityManager = Square_Utility_Doctrine::getEntityManager();

It shows me the following error:


Can anyone please help me out?

share|improve this question
Where does a function called getConnection() come into this? Where is it called? Where is it defined? You didn't state the file and line where the error occurred, but I'm guessing that file/line is not in the code you posted here. –  Wiseguy Jul 2 '12 at 6:05
Oh sorry! $this->entityManager = Square_Utility_Doctrine::getEntityManager();$this->connection = $this->entityManager->getConnection(); –  Isfar Ahmad Sifat Jul 2 '12 at 6:16
Can you now understand? Please, help me –  Isfar Ahmad Sifat Jul 2 '12 at 6:17
Thanks, I've been able to fix it. The code now in the __construct() method should be placed within the getEntityManager(). Because, __construct() isn't called when I call getEntityManager(). Thanks. –  Isfar Ahmad Sifat Jul 2 '12 at 6:24
Isfar, you should answer your own question and accept your own answer. –  Gustav Bertram Jul 2 '12 at 7:35

Your Answer



Browse other questions tagged or ask your own question.