manning-sandbox.com/forum.jspa?forumID=329
5.2.2 Using Zend_Db_Table
In order to actually use the Zend_Db_Table components, you must create a class to represent your table as
shown in Listing 5.6. This is usually named along the same lines as the database table that it accesses, but there
is no requirement for it to do so.
Listing 5.6: Declaring a table class for use with Zend_Db_Table
class Users extends Zend_Db_Table_Abstract
{
protected $_name = 'users'; #1
}
(annotation) <#1. The name of the database table is explicitly set>
As you can see, in listing 5.1, we have explicitly set the name of the underlying table to ???users???. In reality,
if the $_name property is not set, the name of the class the name of the class (preserving the case) will be used
instead. I prefer to name my classes starting with an upper case letter and name my database tables entirely in
lower case, hence it is wise for me to explicitly declare the database table name.
Now that we have a Users class, we can fetch data from the table in exactly the same way as if we were
collecting data from an instance of Zend_Db_Adapter:
$users = new Users();
$rows = $users->fetchAll();
Whilst it performs the same functionality, the Zend_Db_Table_Abstract::fetchAll() is used completely
differently from Zend_Db_Adapater_Abstract::fetchAll().
Pages:
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160