How to change Zend_Db_Table name within a Model to insert in multiple tables
- by jwhat
Using Zend Framework, I've created a Model to insert a record into a database. My question is, after $this->insert($data) how can I switch the active table so that I can insert a record into another table?
Here's my code so far:
class Model_DbTable_Foo extends Zend_Db_Table_Abstract
{
protected $_name = 'foo';
public function addFoo($params)
{
$data = array(
'foo' => $params['foo'],
);
$this->insert($data);
$foo_id = $this->getAdapter()->lastInsertId();
$data2 = array(
'bar' => $params['bar']
);
// I need to change the Db Table name here.
$this->insert($data2);
$bar_id = $this->getAdapter()->lastInsertId();
}
}