thinkphp在数据库中增加和修改失败
<?phpnamespaceHome\Controller;useThink\Controller;classIndexControllerextendsControll...
<?phpnamespace Home\Controller;use Think\Controller;class IndexController extends Controller {public function index(){ $Users=D("users"); $attr=$Users->select(); $this->assign("canshu",$attr); $this->display(); dump($Users->select()); } function delete($user_id) { $Users=D("Users"); $r=$Users->delete($user_id); if($r) { $this->success("删除成功",U("index")); } else { $this->error("删除失败"); } } function insert(){ $Users = D('Users'); if($Users->create()) { $result = $Users->add(); if($result) { $this->success("数据添加成功!",U("index")); }else{ $this->error('数据添加错误!'); } }else{ $this->error($Users->getError()); } } function edit($id=0){ $Users = M('Users'); $this->assign('vo',$Users->find($user_id)); $this->display(); } function update(){ $Users = D('Users'); if($Users->create()) { $result = $Users->save(); if($result) { $this->success('操作成功!',U("index")); }else{ $this->error('写入错误!'); } }else{ $this->error($Users->getError()); } }}
展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |