Re: [fw-general] Custom Libraries

2007-02-18 Thread Yann Nave

I think it's good for usage.
It will be good to have method like this in Zend_Db_Table to pass only data
to the view script ! :)

On 2/17/07, Craig Slusher <[EMAIL PROTECTED]> wrote:


I have attached an example of two classes I have created which have
helped make my code less error-prone and more modular. The classes
provided wrap the Zend_Db_Table_Row and Zend_Db_Table_Rowset objects,
making them Immutable. This has proven very beneficial when I need to
pass instances of these objects to a view.

By wrapping them in these Immutable objects, I can prevent a template
designer from altering data in any way. It is also more efficient than
converting to an array, since I still implement the Iterator and
Countable interfaces in these objects.

Example:

$photo_table = new PhotoTable(); // PhotoTable extends Zend_Db_Table
$photo = $photo_table->find(1);

// Passes an immutable instance of this object to the view.
$view->photo = new Sleek_Db_Table_ImmutableRow($photo);

$album_table = new AlbumTable(); // AlbumTable extends Zend_Db_Table
$albums = $album_table->fetchAll('parent_id IS NULL');

// Immutable rowset object.
$view->albums = new Sleek_Db_Table_ImmutableRowset($albums);

Check out the attachment and let me know what you think. I'd be
interested to know if anyone finds this type of thing useful.

--
Craig Slusher
[EMAIL PROTECTED]





--
Yannux
http://blog.onbebop.net


[fw-general] Custom Libraries

2007-02-17 Thread Craig Slusher

I have attached an example of two classes I have created which have
helped make my code less error-prone and more modular. The classes
provided wrap the Zend_Db_Table_Row and Zend_Db_Table_Rowset objects,
making them Immutable. This has proven very beneficial when I need to
pass instances of these objects to a view.

By wrapping them in these Immutable objects, I can prevent a template
designer from altering data in any way. It is also more efficient than
converting to an array, since I still implement the Iterator and
Countable interfaces in these objects.

Example:

$photo_table = new PhotoTable(); // PhotoTable extends Zend_Db_Table
$photo = $photo_table->find(1);

// Passes an immutable instance of this object to the view.
$view->photo = new Sleek_Db_Table_ImmutableRow($photo);

$album_table = new AlbumTable(); // AlbumTable extends Zend_Db_Table
$albums = $album_table->fetchAll('parent_id IS NULL');

// Immutable rowset object.
$view->albums = new Sleek_Db_Table_ImmutableRowset($albums);

Check out the attachment and let me know what you think. I'd be
interested to know if anyone finds this type of thing useful.

--
Craig Slusher
[EMAIL PROTECTED]


sleeklib-0.1.tar.gz
Description: GNU Zip compressed data