[英]Laravel 5.2 SQLSTATE[42S02]: Base table or view not found: 1146 Table
My project was running well. 我的项目运行良好。 After adding 3 new columns to a table, I run a artisan command 在向表中添加3个新列后,我运行了artisan命令
php artisan migrate:refresh
But action did not complete. 但是行动没有完成。 After that, when I run any migration command, it is throwing an error massage . 之后,当我运行任何迁移命令时,都会引发错误消息。
[Illuminate\\Database\\QueryException] [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) SQLSTATE [42S02]:找不到基表或视图:1146表'telemedicine.users'不存在(SQL:从status
= 0且mailconfirm
= 1的users
中选择*)
Note: 注意:
I deleted all tables and run php artisan migration
But the problem remains. 我删除了所有表并运行php artisan migration
但问题仍然存在。 II can't understand why. 我不明白为什么。
(SQL: select * from `users` where `status` = 0 and `mailconfirm` = 1)
This query is running in migration period. 该查询在迁移期间运行。
Thank you Everybody. 谢谢大家。 I have already solved my problem. 我已经解决了我的问题。 I used a function getAllinactiveUsers in boot function of AppServiceprovider class . 我在AppServiceprovider类的 启动功能中使用了功能getAllinactiveUsers 。 The dafination of getAllinactiveUsers function was written in the Model Class . getAllinactiveUsers函数的定义是在Model类中编写的。 So when I tried to run php artisan command to create table in the phpMyadmin , The getAllinactiveUsers was invoked before creating the table. 因此,当我尝试运行php artisan命令在phpMyadmin中创建表时,在创建表之前会调用getAllinactiveUsers 。 For this reason such Error was throwing. 因此,抛出了此类错误。
Solution:
Just commented The getAllinactiveUsers function from AppServiceprovider class , and run php artisan command. 刚刚评论了AppServiceprovider类的getAllinactiveUsers函数,并运行php artisan命令。 Everything is ok. 一切都好。
Try adding the name of the tables to your Model Class. 尝试将表的名称添加到模型类中。 public $table = "users"; public $ table =“用户”;
请正确检查您的验证,例如'tag'=>'required | unique:tag | max:255'错误'tag'=>'required | unique:tags | max:255'正确
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.