'Laravel: The save function does not work properly when updating a row with the Postgres database

$movie = Movie::find(1855613);
$movie->title = 'Ponteng School';
$movie->save();

This code not only updates the given ID, It is updates all my rows with the same title. After the disaster, I had to restore the backup of the 10 GB size database. Luckily I had a backup.

I was running the same code on MySQL server it is working fine, but on Postgres server it is not working as I like. I saw the problem was save function then I skipped save function and use update function

Movie::where("id", 1855613)->update(["title" =>'Ponteng School']);

  • Laravel Version: 8.75
  • PHP Version: 8.0
  • Database Driver & Version: pgsql & postgres (PostgreSQL) 12.9 (Ubuntu 12.9-0ubuntu0.20.04.1)

Do you have any thoughts about this issue?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source