2017-05-24 25 views
0

我試圖找到支付,其中user_id等於1與skyrim表及其關係。Laravel - MariaDB服務器版本的正確語法使用

我執行的代碼是:

$user_payout = Payout::fromTable('skyrim')->where('user_id',1)->with('game','cluster')->first(); 
     dd($user_payout); 

它給我這個錯誤:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where user_id = ? limit 1' at line 1 (SQL: select * where user_id = 1 limit 1)

有什麼理由這樣做不起作用?

回答

1

嘗試獲取的數據會首先再做關係

$model = (new Payout)->setTable('skyrim')->where('user_id', 1)->first(); 

if($model) { 
    $model->load('game','cluster'); 
} 
+0

哈哈,第二次幫助我成功的渴望加載。謝謝:) – rebirth1078

+0

歡迎您;) – Aboudeh87

相關問題