R
R
Rishat Sultanov2017-05-03 21:44:28
MySQL
Rishat Sultanov, 2017-05-03 21:44:28

How to talk to the DB facade and find out how it worked?

Good evening gentlemen :)

DB::table('zagon_all')->where('id', '=', $number_animals)->delete();

There is such a query and the fact is that it works without visual warnings even if there is no such ID ($number_animals).
How can I make a check that this query did not delete the element because it is not in the table. (ID)
For now I am catching these IDs that the user entered and immediately entered into another table, and IDs that did not pass the request fly in. Because they didn't exist :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D3lphi, 2017-05-03
@rishatss

The delete() method returns a boolean value (true/false) depending on whether the request was successful or not. Check it out for him.
Judging by your question, you do not understand what a facade is. The facade itself does not implement or "work out" anything, it only takes the object out of the container and calls the method that you "called from the facade" on it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question