I saw that the issue has been set to Fixed by always returning a
Zend_Db_Table_Rowset.
It may be too late, but I thinks that's counter-intuitive to do:
$table->find(42)->current();
To me, the issue is simple :
- if the argument is an array, find() returns a Zend_Db_Table_Rowset
- if the argument is scalar, find() returns a Zend_Db_Table_Row or
false if no result
And if we still want to improve: why do we have Zend_Db_Table_Rowset ?
It seems overkill to me (another layer/stack on top of a PHP's native
type), and doesn't embrace the KISS principle of PHP's array :
$table->find(42); # return Zend_Db_Table_Row for ID = 42
$table->find(array(7, 17)); # returns an array for Zend_Db_Table_Row
objects with IDs in (7, 17)
$table->find(array(42)); # returns an array for the Zend_Db_Table_Row
object with ID = 1
I haven't followed the design/development process of the Zend_Db_Table
component at the beginning, so perhaps I've missed something...
In fact, I don't underdstand very wall some API designs choices in
Zend_Db_Table.
On Thu, Nov 1, 2007 at 13:53, Joó Ádám <ceriak@gmail.com> wrote:
> Hello,
>
> I just wonder why Zend_Db_Table's find() returns a rowset if I query
> against the table specifying only one primary key. I think, this is
> the most often use case of the method, and then calling current() on
> the rowset is so awkward...
> I found this issue: http://framework.zend.com/issues/browse/ZF-21 so I
> see, that this more natural behaviour was the original.
> To solve the problem described in the above issue and to have an
> elegant way to retrieve exactly one row, I suggest to use two
> different methods, like find() and findMany() or something like
> these...
>
>
> Ádám
>
--
Julien Huang
Net Avenir
01 45 82 42 20
06 15 81 63 78
没有评论:
发表评论