6 months ago

Multiple model updating

Posted 6 months ago by keizah

Hello, maybe there is alternative way to update couple model at once?

$neighbours = Category::where('left', '>', $category->right);

    'left' => DB::raw('`left`+2'),
    'right' => DB::raw('`right`+2'),

In localhost example above is working fine, but in heroku I am getting QueryException

SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "`+"
LINE 1: update "categories" set "left" = `left`+2, "right" = `right`...
^ (SQL: update "categories" set "left" = `left`+2, "right" = `right`+2, "updated_at" = 2019-06-05 08:14:26 where "left" > 2)

Please sign in or create an account to participate in this conversation.