« Return to Thread: New ideas/questions for Zend_Db_Table
<?php
class Accounts extends Zend_Db_Table_Abstract
{
protected $_name = 'accounts';
protected $_dependentTables = array('Bugs');
}
class Products extends Zend_Db_Table_Abstract
{
protected $_name = 'products';
protected $_dependentTables = array('BugsProducts');
}
class Bugs extends Zend_Db_Table_Abstract
{
protected $_name = 'bugs';
protected $_dependentTables = array('BugsProducts');
protected $_referenceMap = array(
'Reporter' => array(
'columns' => 'reported_by',
'refTableClass' => 'Accounts',
'refColumns' => 'account_name'
),
'Engineer' => array(
'columns' => 'assigned_to',
'refTableClass' => 'Accounts',
'refColumns' => 'account_name'
),
'Verifier' => array(
'columns' => array('verified_by'),
'refTableClass' => 'Accounts',
'refColumns' => array('account_name')
)
);
}
class BugsProducts extends Zend_Db_Table_Abstract
{
protected $_name = 'bugs_products';
protected $_referenceMap = array(
'Bug' => array(
'columns' => array('bug_id'),
'refTableClass' => 'Bugs',
'refColumns' => array('bug_id')
),
'Product' => array(
'columns' => array('product_id'),
'refTableClass' => 'Products',
'refColumns' => array('product_id')
)
);
}
Hi all,
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
- enable preFetch for one to many relationships (one SELECT for all related,
php assigns each record to the related table
- easy way to cache complete objects with relations
- some kind of a singleton implementation for TableClasses (static class
like the registry? or get instance in each table class)
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?
Best regards
--
View this message in context: http://www.nabble.com/New-ideas-questions-for-Zend_Db_Table-tf4808143s16154.html#a13756929
Sent from the Zend Framework mailing list archive at Nabble.com.
« Return to Thread: New ideas/questions for Zend_Db_Table
| Free embeddable forum powered by Nabble | Forum Help |