Zend Framework を使用して、レコードをデータベースに挿入するモデルを作成しました。私の質問は、$this->insert($data)
レコードを別のテーブルに挿入できるように、アクティブなテーブルを切り替えるにはどうすればよいですか?
これまでの私のコードは次のとおりです。
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();
}
}