I'm wondering if there is a simple way to fetch just a single row or value from a database query. I'm ending up with code that looks like this, and it looks like kind of a mess:
$result = DB::select()->from('users')->where('email', $email)->execute();
$result = $result->as_array();
$row = $result[0];
Not to mention error checking, Seems like it could be taken care of simply with something like this:
$row = DB::select()->from('users')->where('email', $email)->execute()->row();
or
$value = DB::select('user_id')->from('users')->where('email', $email)->execute()->value();
Is there already a way to do this?
Thanks,
Brad