Laravel - does an update increase ID?

Hi guys,

I am making an API using Laravel. In one of my scripts, I am doing an update in a field, for example:

user::where('uuid', $uuid)->update(['date' => $date]); 

I noticed that this increases the primary key. My obvious conclusion is that Eloquent makes an exception - insert instead of a regular MySQL update.

So the question is why?

Thanks.

+5
source share
1 answer

This line of code cannot update the identifier of your records. Whenever you do something strange in your application (not only in Laravel), you should:

  • analyze what exactly the code that causes this problem works (for example, you think that the error is on this line, but you also perform other user-defined functions where the error may occur).
  • check if additional code-dependent code is running - in this case events for user model
  • check if there are any triggers in the database (which will automatically update / insert / delete records)
+1
source

Source: https://habr.com/ru/post/1239037/


All Articles