Some typical model layer in Zend Framework
Posted: Thu May 24, 2007 8:26 am
My future application needs to manage tests and task like Moodle module Quiz plus some user management.
I assume that all work with DB table will be set up in one class. For example all select, update and delete queries will be set up in UserTable like class.
In the first place I was thinking about something like this: http://rudy.mif.pg.gda.pl/~skorp/stuff/ss.png
where all queries for table 'users' where set up in User_Manager class. User_Manager can factor User which is contener for users table's row. User::__construct() and User::update() metods use User_Manager class to deal with DB.
Later I found that all metods in Manager classes can be just static metods in factored classes.
Simply: User::drop(), User::findByCol().
But there is a problem with Zend_Db_Table_Abstract because all desirable metods are unfortunately not static.
The question is: what's the best choice?
a) choose first (featured by diagram) model
b) overwrite Zend_Db_Table_Abstract making all needed static metods (a lot of work!)
c) make something different (what?)
I assume that all work with DB table will be set up in one class. For example all select, update and delete queries will be set up in UserTable like class.
In the first place I was thinking about something like this: http://rudy.mif.pg.gda.pl/~skorp/stuff/ss.png
where all queries for table 'users' where set up in User_Manager class. User_Manager can factor User which is contener for users table's row. User::__construct() and User::update() metods use User_Manager class to deal with DB.
Later I found that all metods in Manager classes can be just static metods in factored classes.
Simply: User::drop(), User::findByCol().
But there is a problem with Zend_Db_Table_Abstract because all desirable metods are unfortunately not static.
The question is: what's the best choice?
a) choose first (featured by diagram) model
b) overwrite Zend_Db_Table_Abstract making all needed static metods (a lot of work!)
c) make something different (what?)