2009年1月21日星期三

[fw-db] Wrong arguments not detected when using Zend_Db_Table_Row magic methods

Hi all,

I had this morning some troubles using a Select object with a
Zend_Db_Table_Row->findParentRow magic method. I was using a
Zend_Db_Select instead of a Zend_Db_Table_Select, but I don't understood
my mistake before some (long) debugging.

The Zend_Db_Table_Row::findParent/DependentRow/Rowset methods expect a
Zend_Db_Table_Select, so if you call it directly, you'll have an
execution error (Zend_Db_Table_Select expected, Zend_Db_Select given).
It's highly clear and comprehensive.

But if you use the magic methods (as with
$row->findParentMyTable($instance_of_zend_db_select)), the __call method
transform all non-Zend_Db_Table_Select object into null. You have a
wrong request, without any execution error. Won't it be more clear for
developpers to throw an exception when argument is not null and not an
instance of Zend_Db_Table_Select ?

Nevertheless, great thanks to all the Zend Framework community, wich
offers us a fantastic framework, and permit to save much and much time.
Lucas

没有评论: