I cannot figure out how to correctly map a DbTable model to a database row in a table in my DB and correspondingly extend this DbTable model to another model so that I can insert a new row. Any simple examples and explanation would be very helpful, as I am struggling in the logic of this problem. Thanks.
Asked
Active
Viewed 438 times
2
-
What exactly do you mean by 'model' here? – ChrisA Oct 25 '13 at 14:41
-
Check out my answer below. My DbTable tells each model which table I am using once I extend it to my model – Justin Oct 29 '13 at 13:46
1 Answers
2
I figured it out. For example, in my Application_Model_DbTable_ExTable add
protected $_name = 'ExTable';
This way Zend will know which table in the database to use.
I then extended Application_Model_DbTable_ExTable to my Application_Model_ExTable, and once I did that I was able to insert into my database using an array such as
public function ExFunction ($example){
$data = array(
'example_column_name' => $example,
);
$this->insert($data);
}