« Return to Thread: New ideas/questions for Zend_Db_Table

Re: New ideas/questions for Zend_Db_Table

by weierophinney :: Rate this Message:

Reply to Author | View in Thread

-- dinok <dino.knoll@...> wrote
(on Wednesday, 14 November 2007, 01:27 PM -0800):
> I am currently working on some improvements for Zend_Db_Table.
> These improvements provide an easier and faster way for database
> relationships.
> As I've often seen, many people want to be able to use JOINs and other
> things.
>
> So my improvements are:
> - enable JOINs for one to one relationships

You may want to look at the work Simon Mundy is doing. He's adding
support for Zend_Db_Select in Zend_Db_Table, and part of this is the
ability to return result sets from JOINs.

> - enable preFetch for one to many relationships (one SELECT for all
> related, php assigns each record to the related table

If you do this, it should be optional. I know many situations where I
only use the related table data in a fraction of requests to the parent
table.

> - easy way to cache complete objects with relations

This would be nice.

> - some kind of a singleton implementation for TableClasses (static class
> like the registry? or get instance in each table class)

Perhaps a factory that uses Zend_Registry for storage? This would
promote re-use, and be pretty lightweight.

> The first two points are working in a early status, but now my problem:
> If I got a resultset with 10 rows and each of these rows(e.g. users)  owns
> zero, one or many related rows (e.g. email addresses), I always put
> references of the tables in the rowsets.
> This has two negative consquences. One the one hand, the memory is
> unnessesary spent and on the other hand you are not able to keep the related
> objecs small (e.g. for caching).
> So why don't we build a connection manager, which holds each table and we
> just refer to the TableClassName instead of the instance?
> And just if we need the table (manipulating rows), we get the reference from
> the connection manager.
>
> Is this a good idea or do I miss anything?

I think I'd need to see an implementation to better understand the
concerns.

--
Matthew Weier O'Phinney
PHP Developer            | matthew@...
Zend - The PHP Company   | http://www.zend.com/

 « Return to Thread: New ideas/questions for Zend_Db_Table