开发者

Fatal Error when using Doctrine ORM with Zend Framework

I am having a little play with an ORM but I am struggling to get off the starting blocks. I am familiar with Zend_Db and was hoping Doctrine would work in a similar way but with more flexibility.

I've followed the various tutorials, to integrate Doctrine with Zend Framework, which are available. All these tutorials more or less say the same thing.

I have made some base Doctrine_Record Classes and as far as I can gather you use Doctrine_Table in the same way you would use Zend_Db_Table_Abstract.

I haven't figured out yet how you would tie a Record object to a Table object, but that's another story.

The problem I have is when I try and fetch a table instance using...

    $role = Doctrine_Core::getTable('Admin_Model_RoleTable');

I get a series of fatal errors...

    Catchable fatal error: Argument 2 passed to Doctrine_Table::__construct() 
    must be an instance of Doctrine_Connection, none given

    Catchable fatal error: Argument 1 passed to Doctrine_Configurable::setParent()
    must be an instance of Doctrine_Configurable, null given

    Call to a member function addTable() on a non-object

I don't know whether it has anything to do with the autoloaders, but as the table models are in the scope of the Module's resources I wouldn't think that would be a problem.

I should add that in my bootstrap I have added a connection that hijack开发者_Go百科s Zend_Db's PDO just for this test.

    $manager = Doctrine_Manager::getInstance();
    $manager->connection($this->getResource('db')
            ->getConnection(), 'db'); 


I have discovered what I was doing wrong. I was trying to reference an instance of Doctrine_Table when I should have been referencing an instance of Doctrine_Record.

The method name Doctrine_Core::getTable() was misleading

These leaves me with more questions on how to structure the models?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜