2

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.

2
  • What exactly do you mean by 'model' here? Commented Oct 25, 2013 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 Commented Oct 29, 2013 at 13:46

1 Answer 1

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);            
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.