ITPub博客

首页 > IT职业 > IT图书 > php表单处理-143

php表单处理-143

IT图书 作者:tankII 时间:2021-09-09 09:22:19 0 删除 编辑

一个表单同时写入两个表(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("添加成功!");

} else {

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

}

           } else {

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

           }


       } else {

           $this->display();

}

}


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1795/viewspace-2809750/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2022-07-18

  • 博文量
    0
  • 访问量
    5736