thinkphp错误积累与总结
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了thinkphp错误积累与总结相关的知识,希望对你有一定的参考价值。
1,非法请求:index/user/addlist
使用两种类似的url分别请求两个方法
这两个方法:
public function add6(){
$user[‘nickname‘] = "陈六";
$user[‘email‘] = "[email protected]";
$user[‘birthday‘] = strtotime("1993-12-12");
if($result = UserModel::create($user)){
return "用户[".$result->nickname.":".$result->id."]新增成功";
}else{
return UserModel::getError();
}
}
public function addlist(){
$user = new UserModel;
$userlist = [
[‘nickname‘=>‘周八‘, ‘email‘=>‘[email protected]‘, ‘birthday‘=>strtotime(‘1991-04-20‘)],
[‘nickname‘=>‘夏九‘, ‘email‘=>‘[email protected]‘, ‘birthday‘=>strtotime(‘1990-02-28‘)],
];
if($user->saveAll($userlist)){
return "用户批量新增成功";
}else{
return "用户批量新增出错";
}
}
路由规则:
return [
‘__pattern__‘ => [
‘name‘ => ‘\\w+‘,
],
‘[hello]‘ => [
‘:id‘ => [‘index/hello‘, [‘method‘ => ‘get‘], [‘id‘ => ‘\\d+‘]],
‘:name‘ => [‘index/hello‘, [‘method‘ => ‘post‘]],
],
‘user/index‘ => ‘index/user/index‘,
‘user/create‘ => ‘index/user/create‘,
‘user/add‘ => ‘index/user/add‘,
‘user/add_list‘ => ‘index/user/addList‘,
‘user/update/:id‘ => ‘index/user/update‘,
‘user/delete/:id‘ => ‘index/user/delete‘,
‘user/:id‘ => ‘index/user/read‘,
];
以上是关于thinkphp错误积累与总结的主要内容,如果未能解决你的问题,请参考以下文章