Skip to end of metadata
Go to start of metadata

<ac:macro ac:name="info"><ac:parameter ac:name="title">Zend_Db_Table_Rowset_Recursive_Abstract - Adrian Hope-Bailie</ac:parameter></ac:macro>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

Zend Framework: Zend_Db_Table_Recursive_Abstract Component Proposal

Proposed Component Name Zend_Db_Table_Recursive_Abstract
Developer Notes http://framework.zend.com/wiki/display/ZFDEV/Zend_Db_Table_Recursive_Abstract
Proposers Adrian Hope-Bailie
Revision 1.0 - 14 September 2007: Initial Proposal. (wiki revision: 9)

Table of Contents

1. Overview

Zend_Db_Table_Rowset_Recursive_Abstract extends Zend_Db_Table_Rowset_Abstract and implements RecursiveIterator.
This allows rowsets that extend this class to specify an id column and a cloumn that references a parent row.
This in turn will allow the rowset to be iterated using regular foreach loops and return information such as the depth of iteration etc.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will extend the existing Zend_Db_Table_Rowset_Abstract class.
  • This component will implement the RecursiveIterator interface.
  • This component will implement the RecursiveIterator interface.
  • This component will support the standard Zend_Db_Table_Rowset_Abstract constructor argument (array $config)

4. Dependencies on Other Framework Components

  • Zend_Db_Table_Rowset_Abstract

5. Theory of Operation

The component extended in the same way as it's parent class. The user may then specify that Zend_Db_Table_Abstract child objects use the child of Zend_Db_Table_Rowset_Recursive_Abstract as their rowset class. Following this rowsets returned by functions on Zend_Db_Table_Abstract (find, fetchAll) can be iterated recursively returning child rows too.

6. Milestones / Tasks

  • Milestone 1:[DONE] Design notes will be published on this page
  • Milestone 2: Working prototype checked into the incubator supporting use case #1
  • Milestone 4: Unit tests exist, work, and are checked into SVN.
  • Milestone 5: Initial documentation exists.

If a milestone is already done, begin the description with "[DONE]", like this:

  • Milestone #: [DONE] Unit tests ...

7. Class Index

8. Use Cases

UC-01

DB table containing comments that can be threaded.
EG:

TABLE: Comments
COLUMNS:
id int (11) not null
parent_id int (11) allow null
user_id int (11) not null
comment text

Here comments that are children of a parent contain the id of the parent comment in the parent_id column, otherwise they contain null.

Model:

application/models/MyComments.php

Implementation of component:

library/My/Db/Table/Rowset/Recursive.php

Comments controller:

application/controllers/CommentsController.php

Comments view:

application/views/scripts/Comments/index.phtml

9. Class Skeletons

]]></ac:plain-text-body></ac:macro>

]]></ac:plain-text-body></ac:macro>

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Sep 16, 2007

    <p>It looks great. It is basicaly what I started to do for my own project.</p>

    <p>I am just wondering, if at a conceptual level, it would not be better to make "recursive" a relationship between table ie: adding it to the _referenceMap of the a "normal" Zend_Db_Table. I am not sure it would work with the existing version of Zend_Db_Table and how to make it to do so.</p>

    <p>Then your Zoopy_Db_Table_Rowset_Recursive_Abstract would still be necessary.</p>

  2. Sep 20, 2007

    <p>That's great, in a certain way, it joins my idea of improving Zend_Db_Table_Rowset capabilities by making it seekable throught SPL.<br />
    I exposed it here : <a class="external-link" href="http://framework.zend.com/issues/browse/ZF-1911">http://framework.zend.com/issues/browse/ZF-1911</a></p>

    <p>I'm interested in both those ideas, I will certainly contribute in a UC code to Incubator soon.</p>

  3. Oct 09, 2007

    <p>I have used this in an App I am working on with great success.</p>

    <p>Using other SPL functions and classes such as filters are incredibly useful with Zend_Db_Table_Rowset as is implements both Iterable and Count.</p>

  4. May 13, 2008

    <p>What is the state of this proposal? Adrian, do you plan on driving this to recommendation?</p>

    <p>,Wil</p>

  5. Jun 20, 2008

    <p>It looks like a great proposal and appears nearly complete, but since we're not hearing back from Adrian, I must move it to the Archived section. <ac:emoticon ac:name="sad" /><br />
    Adrian, if you'd like to finish this proposal and drive it through the proposal process, simply move it back out of the Archived section in to the appropriate section and make updates as usual.</p>

    <p>,Wil</p>