How can I validate it?
If I use:
$res = DB::table('estacaohs')
->whereRaw($sql)
->get();
if ($res->exists()) { /* do something */ }
It works when there are no rows, but when there are, it returns an array, and then this code throws an error since $result is an array and not a Collection.
Does Laravel offer any way to validate this?
Doesn't the query builder always return an array? So couldn't you just do this?
if (empty($res)) {
// do something
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community