2009年7月15日星期三

[fw-db] Zend_Db_Table concrete instantiation

Hello all!

I have commited to trunk a new feature for Zend_Db_Table that will be in
ZF 1.9. That feature is the ability to use concrete instantiation on
tables. What does that mean? It means this is possible:

$authorTable = new Zend_Db_Table('author');
$authors = $authorTable->fetchAll();
foreach ($authors as $author) {
echo $author->id . ': '
. $author->first_name . ' '
. $author->last_name . PHP_EOL;
}

On the more complex side, you are able to define a definition that would
house all the same rules you previously had to define your Zend_Db_Table
inherited classes with.

Without going into the gory details, please see this url below for all
of the working use cases I have attempted to solve:

http://framework.zend.com/svn/framework/standard/branches/user/ralph/ZendDbTable/scripts/

You are free to check out that folder from svn, and run and play with
those scripts. There is a complete sqlite database, and the bootstrap
for that mini set of script will recreate the sqlite file database on
each run.

The only use case which is deprecated as of 1.9 will be if you are
extending Zend_Db_Table (not Zend_Db_Table_Abstract), and are attempting
to instantiate the class via a string, where the string represents the
key name in the registry of the database adapter. Since Zend_Db_Table
has been deprecated since 0.9, I don't this should be a problem for anyone.

Please test out this new feature, and report back any issues to me.

Thanks & Happy ZF'ing!

-ralph

没有评论: