$result = \DB::select()->from('faq')->where('faq_id', $faq_id)->execute()->as_array();
return isset($result[0]) ? $result[0] : false;
// in your method
return \DB::select()->from('faq')->where('faq_id', $faq_id)->execute()->as_array();
// in your controller (random class and method name)
$result = Class::getrow();
if ($result)
{
// there was a result! If not, an empty array evaluates to false.
}
Brad Proctor wrote on Thursday 26th of January 2012:How do you guys normally select a single row? Here is what I've got, but it seems a little weird:
$result = \DB::select()->from('faq')->where('faq_id', $faq_id)->execute()->as_array(); return isset($result[0]) ? $result[0] : false;
$data = \DB::select()->from('table')->where('id', 1)->execute()->current();
It looks like you're new here. If you want to get involved, click one of these buttons!