1. 程式人生 > >TP5錯誤:SQLSTATE[42S02]: Base table or view not found: 1146 Table 'blog.tp_' doesn't exist

TP5錯誤:SQLSTATE[42S02]: Base table or view not found: 1146 Table 'blog.tp_' doesn't exist

TP中,出現SQLSTATE[42S02]: Base table or view not found: 1146 Table 'blog.tp_' doesn't exist這樣的錯誤提示,是因為驗證規則中,出現錯誤

namespace app\admin\validate;
use think\Validate;

class Cate extends Validate
{
    protected $rule =   [//驗證規則
        'catename'  => 'require|max:25|unique:cate',//username變數兩個規則:1、require必須填寫;2、最大字元數
    ];

    protected $message  =   [//驗證顯示的資訊提示
        'catename.require' => '名稱必須',//當username變數為空時,提示
//        'catename.require' => '密碼必須',
        'catename.max'     => '名稱最多不能超過25個字元',
    ];

    protected $scene = [//應用場景
        'add'  =>  ['username'=>'require'],//上面的規則使用在dd方法中,且只有變數username和password可用
    ];
}

'catename'  => 'require|max:25|unique:cate'在這句當中,

之前我一直寫的是:'catename'  => 'require|max:25|unique‘,沒有帶後面那個表名,就報上面的錯誤,unique:cate這個意思是:在表cate中,欄位catename是唯一的,這個在官方的教程中,沒有帶,開始我一直就按官方的教程寫的,一直就報開頭的錯誤,不知道這是官方的失誤還是個bug.