5.2.1 What is the Table Data Gateway Pattern?
Zend_Db_Table has three main components: Zend_Db_Table_Abstract, Zend_Db_Table_Rowset and
Zend_Db_Table_Row. As indicated by its name, Zend_Db_Table_Abstract is an abstract class which has to
be extended for each table that it acts as a gate way to. When selecting multiple records from the table, an
instance of Zend_Db_Table_Rowset is returned to you which can then be iterated over to access each
individual row. Each row is an instance of Zend_Db_Table_Row which is itself an implementation of the Row
Gateway pattern. This is shown in Figure 5.1.
Figure 5.1 The Zend_Db_Table components fit together to produce a clean method of managing a database table and its associated
rows.
Whilst, Zend_Db_Table_Abstract is always extended, Zend_Db_Table_Rowset is much less likely to be as it
provides pretty much all you need for handling a set of database rows. In more complicated systems, extending
Zend_Db_Table_Row into an Active Record by adding domain logic to it can help avoid duplicating of the
same code in multiple places, as we??™ll see when we look at how to use the Zend_Db_Table.
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.
Pages:
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159