一个表单同时写入两个表(bureaup,bureaupinfo为两个表名)

 public function addbur() {

       if ($this->isPost()) {

           $db = M("Bureaup");

$info=M("Bureaupinfo");

$_POST['username'] = $_POST['username'] ? $_POST['username'] : AppframeAction::$Cache['username'];

$_POST['inputtime'] = time();

$_POST['inputip'] = get_client_ip();

if ($db->create()) {

//保存主表

if($db->add()){

$id = $db->getLastInsID();

$_POST['lll']['burid'] = $id;

$_POST['lll']['username'] = $_POST['username'] ? $_POST['username'] : AppframeAction::$Cache['username'];

$_POST['lll']['inputtime'] = time();

$_POST['lll']['inputip'] = get_client_ip();

//保存第二张表

$data=$info->add($_POST['lll']);

$this->success("添加成功!<script>setTimeout(function(){window.close();},1000);</script>");

} else {

$this->error("添加失败!");

}

           } else {

               $this->error($db->getError());

           }


       } else {

           $this->display();

}

}