ZF-6611: Zend DbTable Row Class name->path problem
Description
I was using Zend_Application_Module_Autoloader to autoload my resources. I created two classes one extending Zend_Db_Table_Abstract (Users) and the other is a custom row class extending Zend_Db_Table_Row_Abstract (User).
When instantiating these class separately there is no problem. However when I use Table class like with a custom row like the one below. It cant find the file. It looks in "model" directory instead of "models";
class Model_DbTable_Users extends Zend_Db_Table_Abstract { protected $_name ='user'; protected $_primary = 'id'; protected $_rowClass = 'Model_DbTable_User'; }
I am guessing there is a separate Namespace/path converter somewhere else and it is converting differently than Autoloader. This may be helpful \library\Zend\Db\Table\Rowset\Abstract.php(119): Zend_Loader::loadClass('Model_DbRow_Use...')
There is a discussion about this at http://nabble.com/Zend-Model-and-quickstart-tt2344…
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2009-05-12T03:50:06.000+0000
The problem is not that it's looking in the wrong directory so much as it's not using autoloading -- which is an issue throughout the framework currently. We'll be addressing it soon.
Posted by Sinan Taga (defiant) on 2009-05-13T03:51:29.000+0000
Any tips on how to fix this?
Posted by Matthew Weier O'Phinney (matthew) on 2009-05-14T05:45:26.000+0000
Resolved in trunk and 1.8 release branch
Posted by Sinan Taga (defiant) on 2009-05-15T02:05:19.000+0000
I downloaded the from the trunk to give it a try. As you said it now works. However there is another problem (or I'm doing something wrong) which may be related.
Anyway: It seems that even if you set a new rowClass in the table class when you return it, thr returned object is still Zend_Db_Table_Row Object instead of the custom class.
Doesnt work... // Specify a custom Row to be used by default // in all instances of a Table class. class Products extends Zend_Db_Table_Abstract { protected $_name = 'products'; protected $_rowClass = 'MyRow'; }
Does Work // Or specify a custom Row to be used in one // instance of a Table class. $bugs = new Bugs(array('rowClass' => 'MyRow'));