Laravel - MariaDB 服务器版本,用于在附近使用正确的语法

Laravel - MariaDB server version for the right syntax to use near

我正在尝试从天际 table 中找到 user_id 等于 1 的支出及其关系。

我执行的代码是:

$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)

为什么这不起作用?

尝试先获取数据,然后进行关系的预先加载

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

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