SQLSTATE[42S22]:未找到列:1054 “where 子句”中的未知列“id”(SQL:从“歌曲”中选择 *,其中“id” = 5 限制 1)
当用户单击链接时,我正在尝试使用列从数据库中获取特定数据,但我收到此错误:SongID
SQLSTATE[42S22]: 未找到列: 1054 “where 子句” 中的未知列 'id' (SQL: select * from where = 5 limit 1)
songs
id
控制器类:
<?php namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use DB;
class SongsController extends Controller {
public function index()
{
$name = $this->getName();
$songs = DB::table('songs')->get();
return view('songs.index', compact('songs','name'));
}
public function show($id)
{
$name = $this->getName();
$song = DB::table('songs')->find($id);
return view('songs.show', compact('song','name'));
}
private function getName()
{
$name = 'Tupac Amaru Shakur';
return $name;
}
}
迁移:
public function up()
{
Schema::create('songs', function($table)
{
$table->increments('SongID');
$table->string('SongTitle')->index();
$table->string('Lyrics')->nullable();
$table->timestamp('created_at');
});
}