SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from `songs` where `id` = 5 limit 1)

前端 未结 5 1906

I am trying to get specific data from the database by using column SongID when a user clicks a link but I am getting this error:

SQLSTATE[42

5条回答
  •  忘了有多久
    2021-02-02 08:21

    $song = DB::table('songs')->find($id);
    

    here you use method find($id)

    for Laravel, if you use this method, you should have column named 'id' and set it as primary key, so then you'll be able to use method find()

    otherwise use where('SongID', $id) instead of find($id)

提交回复
热议问题