Laravel 5.2 SQLSTATE[42S02]:找不到基础 table 或视图:1146 Table
Laravel 5.2 SQLSTATE[42S02]: Base table or view not found: 1146 Table
我的项目 运行 很好。在 table 添加 3 个新列后,我 运行 一个 artisan 命令
php artisan migrate:refresh
但是动作没有完成。之后,当我 运行 任何迁移命令时,它都会抛出错误消息。
[Illuminate\Database\QueryException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'telemedicine.users' doesn't exist (SQL: select * from users
where status
= 0 and mailconfirm
= 1)
注:
我删除了所有table和运行 php artisan migration
但是问题依旧。我不明白为什么。
(SQL: select * from `users` where `status` = 0 and `mailconfirm` = 1)
此查询 运行迁移期间。
尝试将 table 的名称添加到您的模型 Class 中。
public $table = "users";
谢谢大家。我已经解决了我的问题。我在 boot AppServiceprovider class 函数中使用了函数 getAllinactiveUsers 。 getAllinactiveUsers函数的定义写在模型Class中。所以当我尝试 运行 php artisan 命令在 phpMyadmin[=27 中创建 table =],在创建 table 之前调用了 getAllinactiveUsers。出于这个原因,这样的错误正在抛出。
Solution:
刚刚评论了来自 AppServiceprovider class 和 运行 php artisan 的 getAllinactiveUsers 函数命令。一切正常。
请正确检查您的验证,例如 'tag' => 'required|unique:tag|max:255' 错误
'tag' => 'required|unique:tags|max:255' 正确
我的项目 运行 很好。在 table 添加 3 个新列后,我 运行 一个 artisan 命令
php artisan migrate:refresh
但是动作没有完成。之后,当我 运行 任何迁移命令时,它都会抛出错误消息。
[Illuminate\Database\QueryException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'telemedicine.users' doesn't exist (SQL: select * fromusers
wherestatus
= 0 andmailconfirm
= 1)
注:
我删除了所有table和运行 php artisan migration
但是问题依旧。我不明白为什么。
(SQL: select * from `users` where `status` = 0 and `mailconfirm` = 1)
此查询 运行迁移期间。
尝试将 table 的名称添加到您的模型 Class 中。 public $table = "users";
谢谢大家。我已经解决了我的问题。我在 boot AppServiceprovider class 函数中使用了函数 getAllinactiveUsers 。 getAllinactiveUsers函数的定义写在模型Class中。所以当我尝试 运行 php artisan 命令在 phpMyadmin[=27 中创建 table =],在创建 table 之前调用了 getAllinactiveUsers。出于这个原因,这样的错误正在抛出。
Solution:
刚刚评论了来自 AppServiceprovider class 和 运行 php artisan 的 getAllinactiveUsers 函数命令。一切正常。
请正确检查您的验证,例如 'tag' => 'required|unique:tag|max:255' 错误 'tag' => 'required|unique:tags|max:255' 正确