Skip to end of metadata
Go to start of metadata

<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_Config_Db Component Proposal

Proposed Component Name Zend_Config_Db
Developer Notes http://framework.zend.com/wiki/display/ZFDEV/Zend_Config_Db
Proposers Ben Scholzen
Alexander Veremyev (Zend Liaison)
Revision 1.0 - 10 May 2008: Initial proposal. (wiki revision: 6)

Table of Contents

1. Overview

Zend_Config_Db will allow reading and writing configs to databases supported by Zend_Db_Adapter. This may be useful for runtime stored values, like those which can be set by an administrator panel.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will only connect to the database if values are read or written.
  • This component will allow creating new values and groups at runtime.
  • This component will only query for required values and only catch all values if required by toArray().
  • This component will not support sections, as they are not a requirement for a dynamic config.
  • This component will not support merge (yet?).

4. Dependencies on Other Framework Components

  • Zend_Config

5. Theory of Operation

A Zend_Config_Db object is created with an instance of Zend_Db_Aadapter_Abstract. You may also specify another table name and the column names which are used. After instanciation it can be used like any other Zend_Config object

6. Milestones / Tasks

  • Milestone 1: [DONE] Proposal finished
  • Milestone 2: Waiting for community feedback
  • Milestone 3: Working prototype checked into http://zend.svn.dasprids.de
  • Milestone 4: Unit tests exist, work, and are checked into http://zend.svn.dasprids.de
  • Milestone 5: Proposal approval
  • Milestone 6: Initial documentation exists.

7. Class Index

  • Zend_Config_Db

8. Use Cases

UC-01

Creating a Zend_Config_Db instance

UC-02

Reading a value

UC-03

Writing a value to the database

9. Class Skeletons

Skeletons will follow later

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

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

Labels:
zend_config zend_config Delete
database database Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. May 11, 2008

    <p>Some comments on the Requirements, Constraints, and Acceptance Criteria section:</p>

    <ul>
    <li>If this component can create values and groups, then it is very different from the other Zend_Config component.</li>
    <li>If this component doesn't support sections and inheritance then it is very different from the other Zend_Config components.</li>
    <li>Not all servers are set up to allow the database user permission to create tables. Again, none of the other Zend_Config components create their own data stores.</li>
    </ul>

    <p>Personally, I would suggest moving the creation of values, groups and tables into a sub-class that inherits from Zend_Config_Db. </p>

    <p>Also, I suspect that you need a class skeleton before you can call the proposal finished <ac:emoticon ac:name="smile" /></p>

    1. May 11, 2008

      <p>So, then to make it more like the others, you would want the following stuff I guess:</p>

      <ul class="alternate">
      <li>A new interface, called Zend_Config_Writable_Interface</li>
      <li>Support for sections and inheritance</li>
      <li>Table structure and values/groups <strong>must</strong> be pre-inserted by the developer</li>
      <li>Optionally, but not required at this time, the possibility to register plugins into the Zend_Config_Writable_Db, which allow creation of table structure and groups/values.</li>
      </ul>

      <p>Am I right so far?</p>

      <p>Well and about the the class skeleton: Usually they only show the public methods, and those won't / shouldn't differ from the other Zend_Config classes, exept the constructor for sure.</p>

      1. Jun 10, 2008

        <p>I think that Zend_Config_DB must be able to support sections and inheritence for it to be considered part of Zend_Config.</p>

        <p>I'm not sure what a new interface would do. I think Shahar's intended proposal for Zend_Config_Writer is where the ability for a config object to write persistent data should be concentrated.</p>

        1. Jun 12, 2008

          <p>I don't think that an interface is required, since there come no new methods, which are not in the usual Zend_Config yet.</p>

  2. Jun 24, 2008

    <ac:macro ac:name="note"><ac:parameter ac:name="title">Zend Comments</ac:parameter><ac:rich-text-body>
    <p>We have the following recomendations for the Zend_Config_Db proposal:</p>
    <ul>
    <li>Proposal should indicate DB schema necessary for value storage.</li>
    <li>Proposal should indicate what configuration options are available for configuring the object; does it expect just a table name? or the names of fields? or something else?</li>
    <li>Proposal explicitly does not allow sections or inheritance (merge capability), which other config adapters utilize. This would make its usage inconsistent with the other adapters. This should be solved in one or another way.</li>
    <li>It seems like it should re-use the Zend_Db_Table default adapter if no adapter is specified, or allow passing a table name to utilize.</li>
    </ul>

    <p>Nevertheless, the idea of the proposal is very useful. So the proposal is moved to archived folder now, but is welcome to be extended and moved back to the review process</p></ac:rich-text-body></ac:macro>

  3. Nov 13, 2009

    <p>Modeling the table after XML structure, we would have three different tables - xml_node, xml_node_element, xml_node_element_attribute, however these tables would have very similar columns (name, value, parent_id). So using the Single Table Inheritance Data Model, we could end up with one flat table as following:</p>

    <p>id - int (10) not null unsigned autoincrement<br />
    name - varchar(255) not null<br />
    parent_id - int(10) null unsigned default null<br />
    value - varchar(255) null default null<br />
    config_id - int(10) null unsigned default null<br />
    extends - int(10) null unsigned default null</p>

    <p>unique (parent_id, name)</p>

    <p>Then something like</p>

    <p><production><br />
    <db><br />
    <name>production_db</name><br />
    <password></password><br />
    <host>localhost</host><br />
    <user>root</user><br />
    </db><br />
    </production><br />
    <development extends="production"><br />
    <db><br />
    <name>development_db</name><br />
    </db><br />
    </development></p>

    <p>would be stored as</p>

    <table><tbody>
    <tr>
    <td><p> id </p></td>
    <td><p> name </p></td>
    <td><p> parent_id </p></td>
    <td><p> value </p></td>
    <td><p> config_id </p></td>
    <td><p> extends </p></td>
    </tr>
    <tr>
    <td><p> 1 </p></td>
    <td><p> production </p></td>
    <td><p> NULL </p></td>
    <td><p> NULL </p></td>
    <td><p> 1 </p></td>
    <td><p> NULL </p></td>
    </tr>
    <tr>
    <td><p> 2 </p></td>
    <td><p> db </p></td>
    <td><p> 1 </p></td>
    <td><p> NULL </p></td>
    <td><p> 1 </p></td>
    <td><p> NULL </p></td>
    </tr>
    <tr>
    <td><p> 3 </p></td>
    <td><p> name </p></td>
    <td><p> 2 </p></td>
    <td><p> production_db </p></td>
    <td><p> 1 </p></td>
    <td><p> NULL </p></td>
    </tr>
    <tr>
    <td><p> 4 </p></td>
    <td><p> password </p></td>
    <td><p> 2 </p></td>
    <td><p> </p></td>
    <td><p> 1 </p></td>
    <td><p> NULL </p></td>
    </tr>
    <tr>
    <td><p> 5 </p></td>
    <td><p> user </p></td>
    <td><p> 2 </p></td>
    <td><p> root </p></td>
    <td><p> 1 </p></td>
    <td><p> NULL </p></td>
    </tr>
    <tr>
    <td><p> 6 </p></td>
    <td><p> host </p></td>
    <td><p> 2 </p></td>
    <td><p> localhost </p></td>
    <td><p> 1 </p></td>
    <td><p> NULL </p></td>
    </tr>
    <tr>
    <td><p> 7 </p></td>
    <td><p> development </p></td>
    <td><p> NULL </p></td>
    <td><p> NULL </p></td>
    <td><p> 2 </p></td>
    <td><p> 1 </p></td>
    </tr>
    <tr>
    <td><p> 8 </p></td>
    <td><p> db </p></td>
    <td><p> 7 </p></td>
    <td><p> NULL </p></td>
    <td><p> 2 </p></td>
    <td><p> NULL </p></td>
    </tr>
    <tr>
    <td><p> 9 </p></td>
    <td><p> name </p></td>
    <td><p> 8 </p></td>
    <td><p> developemnt_db </p></td>
    <td><p> 2 </p></td>
    <td><p> NULL </p></td>
    </tr>
    </tbody></table>