Reputation: 2597
When using updating via Eloquent
it returns affected rows as a result. Is it possible somehow to get status of update? For example if I passing some bad id in WHERE
it still return 0 affected rows, though here I need to know that this id does not exist. Basically when the user clicks a save button, but nothing edit - I get 0 affected rows from Eloquent and also when bad id is entered. I need to somehow separate this things.
Upvotes: 0
Views: 191
Reputation: 152880
You could check first if the WHERE
returns anything:
if(Model::where($where)->count() > 0){
// row(s) found > do update
}
else {
// where doesn't match any rows
}
Upvotes: 2