mysql - Eloquent update and get record back -


when update record do

$myobject->update(['field' => 'value']); 

and updates both database , instance $myobject. need bulk update use model facade , do

$result = myobject::where(...)->update(['field' => 'value'); 

the issue here $result sends me boolean instead of updated instances have separately right after need same filter time get().

$objects = myobject::where(...)->get(); 

is there more efficient way update , records in 1 call / request database?

imho way arguably efficient eloquent.

if care performance more using eloquent raw queries in postgresql (with returning clause) or sql server (with output clause) can return updated records in 1 go.

mysql unfortunately doesn't have such support on statement level.

in supported laravel databases can achieve (one trip database) stored procedure.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -