sql - 尝试将表单提交到数据库时出错
问题描述
嗨,所以当我尝试将表单提交到我的数据库时,我收到以下错误
错误
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'urenregistratie.issues' doesn't exist (SQL: insert into `issues` (`iname`, `begroting`, `description`, `updated_at`, `created_at`) values (test, 100, test description, 2019-12-04 09:19:54, 2019-12-04 09:19:54))
控制器
public function store(Request $request)
{
$this->validate($request,[
'iname' => 'required',
'begroting' => 'required',
'description' => 'required',
]);
$issue = new Issue;
$issue->iname = $request->input('iname');
$issue->begroting = $request->input('begroting');
$issue->description = $request->input('description');
$issue->save();
return redirect('/issue')->with('success', 'Data Saved');
}
移民
public function up()
{
Schema::create('issue', function (Blueprint $table) {
$table->increments('id');
$table->string('iname');
$table->time('begroting');
$table->mediumText('description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('issue');
}
}
Urenregistratie 是我的数据库名称。但我不知道它从哪里得到问题,因为我在没有 S 的情况下称它为问题,所以它从哪里得到问题
如果我确实缺少任何代码方面的信息,请告诉我。
解决方案
您的迁移会创建问题表,但您要保存到问题表。检查模型类中的表名。
class Issue extends Model
{
protected $table = 'issue'; // this table name
.
.
.
}
推荐阅读
- python - 获取此 POST 方法 json API 结果的正确方法是什么?
- testing - 在 Katalon Studio 移动测试中,我在定位一个元素“org.openqa.selenium.InvalidSelectorException”时遇到了这个错误
- javascript - 选择前端元素后从数据库中获取对应的值
- powerbi - if 语句之间的 DAX 日期
- html - 如何从下拉菜单中获取选项(每个可能的选择)以嵌入图像
- javascript - 如何使用正则表达式将字符串中的“/”替换为“-”
- babeljs - 无法让 Babel 使用“polyfill”插件进行编译
- neo4j - 在图形数据库中计算各个年份的特定值
- docker - 无法使用 MariaDb docker-compose 获取 PhpMyAdmin
- vscode-tasks - 重用输入变量中的值 pickString - Tasks.json