2015-02-11 21 views
0

我想更新使用雄辯我的數據,但它給了我一些錯誤:雄辯的ORM沒有保存價值laravel

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(); 

請找我哪裏錯了在此代碼中

+0

被稱爲'id'或別的東西你的主鍵列? – lukasgeiter 2015-02-11 19:21:37

+0

我的主鍵叫logo_id – okconfused 2015-02-11 19:25:35

回答

2

因爲您的主鍵列不叫id(這是默認的Laravel假設),所以您必須在您的模型中指定它:

class Logo extends Eloquent { 
    protected $primaryKey = 'logo_id'; 
} 

報價:

Note: Eloquent will also assume that each table has a primary key column named id. You may define a primaryKey property to override this convention.

+0

謝謝lukasgeiter – okconfused 2015-02-11 19:39:26

+0

不客氣:) – lukasgeiter 2015-02-11 19:39:41