TP中,出现SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘blog.tp_’ doesn’t exist这样的错误提示,是因为验证规则中,出现错误
<?php
namespace app\admin\validate;
use think\Validate;
class Cate extends Validate{
protected $rule = [
'catename' => 'require|max:25|unique:cate',
];
protected $message = [
'catename.require' => '栏目名称必须填写',
'catename.max' => '栏目名称长度不得大于25位',
'catename.unique' => '栏目名称不能重复',
];
protected $scene = [
'add' => ['catename'=>'require|unique:cate'],
'edit' => ['catename'=>'require|unique:cate'],
];
}
‘catename’ => 'require|max:25|unique:cate’在这句当中,
之前我一直写的是:‘catename’ => 'require|max:25|unique‘,没有带后面那个表名,就报上面的错误,unique:cate这个意思是:在表cate中,字段catename是唯一的