🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ if (Request::instance()->isPost()) { //不知道以下哪种方法效率最高哦? //User模型静态调用 /* $new_user['user_name'] = Request::instance()->post('user_name'); $new_user['user_password'] = Request::instance()->post('user_password'); if ($result = User::create($new_user)) { return '用户[ ' . $result->user_name . ':' . $result->id . ' ]新增成功'; } else { return '新增出错'; } */ //实例化User模型(不成功) $user = new User; $new_user['user_name'] = Request::instance()->post('user_name'); $new_user['user_password'] = Request::instance()->post('user_password'); $user->data($new_user); $result = $user->save(); if ($result) { return '新增了'.$result.'条数据'; } else { return '新增出错'; } /* //使用助手函数 $user = model('User'); $new_user['user_name'] = input('post.user_name'); $new_user['user_password'] = input('post.user_password'); $user->data($new_user); $result = $user->save(); if ($result) { return '新增了'.$result.'条数据'; } else { return '新增出错'; } */ }else{ return '请检查请求类型。'; } ~~~