2009年8月24日星期一

[fw-db] Zend_Db_Table and primary keys...

I sometimes have tables that don't have primary keys, for example a table
where you have a site_id and an ip address that will be processed by a cron
later to protect the site from shared accounts, etc etc... There is no
primary key possible, because even a timestamp could break with more than
one IP inserted in the same second.

Am I the only one who thinks Zend_Db_Table suffers from trying to do too
much, or at least forcing you into something you might not need or want? The
documentation states the class is an implementation of the Table Data
Gateway pattern, but the class is clearly more specific than the pattern.

Anyway, I guess this will end up being a random rant, but the way I see it,
Zend_Db_Table should be allowed to be used without a primary key, as you see
fit, but should throw exceptions when you're trying to use functionality
that requires a primary key, like find(). I would still use insert and
delete methods (you never need the update method with tables without a
primary key, or I think your database design is faulty, unless you want to
mass update).

Also, bypassing Zend_Db_Table to handle these exceptions is a source of
problem in projects where Zend_Db_Table is the main gateway for data access.
--
View this message in context: http://www.nabble.com/Zend_Db_Table-and-primary-keys...-tp25117083p25117083.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: