我想使用Eloquent更新我的数据,但它给了我一些错误:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'od_logo.id' in 'where clause' (SQL: select * from `od_logo` where `od_logo`.`id` = 1 limit 1)
这是我的代码:
$logo = Logo::find($id);
$logo->logo_logoimg_name = Input::get('logo_name');
$logo->logo_logoimg_path = $logo_destinationPath . $logo_filename;
$logo->logo_faviconimg_name = $favicon_destinationPath . $favicon_filename;
$logo->save();
请找到我在这个代码中做错的地方
因为主键列不是id
(这是Laravel默认的假设),所以必须在模型中指定它:
class Logo extends Eloquent {
protected $primaryKey = 'logo_id';
}
文档中的报价:
注意:Eloquent还假设每个表都有一个名为id的主键列。您可以定义一个primaryKey属性来覆盖此约定。