Reputation: 36273
is it posible to have a true Model Layer in PHP like in Ruby on Rails? With Zend Framework you can create a Model but this is a class. As I know you have to write all the logic by myself.
Solutions?
Upvotes: 4
Views: 831
Reputation: 32144
i wrote a script that might suite your needs.
http://code.google.com/p/zend-db-model-generator/
Upvotes: 1
Reputation: 11217
Or since 1.8.x there is a DataMapper pattern used for models (see quickstart in manual)
Upvotes: 2
Reputation: 3678
True, in Zend Framework you need to declare classes for the database tables you'd like to access. But the rest can be done implicitly, if the default behavious is sufficient. The following is a valid and functional model class (compare to 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 should let you access the table named "bugs", e.g.:
$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.
Upvotes: 3