We
will now consider ways to consolidate our SQL and see how the Zend Framework??™s Zend_Db_Table
component helps to improve the architecture of our applications.
5.2 Table Abstraction: Zend_Db_Table
When dealing with a database, it is useful to be able to abstract your thinking above the nitty-gritty of the
actual SQL statements and consider the system at the domain level. The domain level is where you are
thinking about the problem being solved in the language of the problem. The easiest way to do this is to create
classes that know how to load and save themselves to the database. A class that represents one row in a
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
database table is known as the Row Gateway pattern (or Active Record pattern depending on what else the
class does).
One area where Row Gateway doesn??™t work so well is when dealing with lists such as retrieving a list of
products in an e-commerce application. This is because it works at the row-level and lists are generally dealt
with at the table level. The Zend Framework provides the Zend_Db_Table component to support database
manipulation at the table level and so we will look at what it provides for us and how table level support
differs from what we have already seen with Zend_Db_Adapter.
Pages:
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158