How to change Zend_Db_Table name within a Model to insert in multiple tables

前端 未结 3 1101
余生分开走
余生分开走 2021-01-03 09:37

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

3条回答
  •  迷失自我
    2021-01-03 10:27

    I think you should have another Model_DbTable, Model_DbTable_Bar and call it either

    internally:

    class Model_DbTable_Foo ... {
      public function addFooAndBar() {
        ...
        $bar = new Model_DbTable_Bar();
        $bar->insert($data2);
      }
    }
    

    or externally:

    class ModelX ... {
      public function addFoos() {
        $foo = new Model_DbTable_Foo();
        $foo->insert($data);
        $bar = new Model_DbTable_Bar();
        $bar->insert($data2);
      }
    }
    

提交回复
热议问题