|
|||
|
Just started on the zend framework, and was wondering if every model that requires database access has to extend zend_db_table_row? For instance, if i have an author class, i assume the author finder/ gateway extends zend_db_table? This means that the returned/ found author must extend zend_db_table_row, is that correct? What if the author model contains a collection of books by that author - how is that relationship expressed in terms of zend_db_table and zend_db_table_row? Is it considered good mvc practice to pass models to the view that have a db-accessable interface, or should they be "read-only" objects? Would you always use the zend_db_* interface for db access, or would you ever use pdo directly in a model?
![]() Thanks for any answers, i hope someone can clear this confusion for me ![]() |
|
|||
|
Thanks for the reply.
![]() How likely are you to have more than one adapter in a project? It seems the only viable use would be for different adapters to point to different databases? With regards to my original post, i'll try and explain it a little better. Whereas i'm currently used to creating a model, say Author, and using pdo from within the class to populate it's properties (activerecord i suppose?), after reading the docs on zend_db_table it seems that for any model in the application that requires db access, i need to make it a child of zend_db_table_row, since the gateway returns an object of that type. eg: PHP Code:
PHP Code:
![]() ![]() |
|
||||
|
I see what your saying now I think:
Code:
class Authors extends Zend_Db_Table_Abstract {
//table definition
}
class Author extends Zend_Db_Table_Row {
//individual record from Authors table
}
I currently have a project underway that connects to no less than 6 different dbs on 4 diferent servers, and we're just dealing with infrastructure at the moment, no real function pages have been producted... so yes is very possible within the enterprise to have a set of db adapters as apposed to a single adapter. |
|
||||
|
Here's a free webinar I found that might help, I know I plan on checking it out!
Events / Company / Zend.com |
![]() |
| Thread Tools | |
| Display Modes | |
|
|