Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

richardh's avatar

Check when a query was successful

How would I check this query was successfully executed:

 DB::table('private_messages')->whereIn('id', $remove_ids[0])->delete();
0 likes
3 replies
tykus's avatar

It will return a number of records deleted.

richardh's avatar

would I do something like if (!delete()) ?

tykus's avatar
tykus
Best Answer
Level 104

It depends...

You could do something like the following, or assign the result to a variable;

if (DB::table('private_messages')->whereIn('id', $remove_ids[0])->delete()) {
    // more than 0 records were deleted
}
1 like

Please or to participate in this conversation.