Zend Framework Model

Is it possible to have a real model layer in PHP, for example, in Ruby on Rails? With the Zend Framework, you can create a model, but it is a class. As I know, you must write all the logic yourself.

Solutions?

+4
source share
3 answers

True, in the Zend Framework you need to declare classes for the database tables that you want to access. But everything else can be done implicitly, if the default is enough. The following is a valid and functional class for the model (compare with http://framework.zend.com/manual/en/zend.db.table.html#zend.db.table.introduction ):

class bugs extends Zend_Db_Table_Abstract { // table name matches class name } 

This will allow you to access a table named "errors", for example:

 $table = new bugs(); $data = array( 'created_on' => '2007-03-22', 'bug_description' => 'Something wrong', 'bug_status' => 'NEW' ); $table->insert($data); 

Again, the example was taken directly from the documentation mentioned above.

+3
source

Or with 1.8.x there is a DataMapper template used for models (see quick start in the manual)

+2
source

I wrote a script that can satisfy your needs.

http://code.google.com/p/zend-db-model-generator/

+1
source

All Articles