public static function get_advice($id) { $result = DB::select('*')->from('advice')->where('id', $id)->execute(); if ( DB::count_last_query() > 0 ) { $result_array = $result->as_array(); foreach($result_array as $row) { // return one row of advice return($row); } } // row not found return(FALSE); }I get this error message, pointing at the DB::select... in the above function
Why is it not recognizing the call to the DB class?ErrorException [ Error ]: Class 'Model\DB' not found
$result = \DB::select('*')->from('advice')->where('id', $id)->execute();Which doesn't stop the error from occurring. I miss your hobbit reference, too obtuse... How would you recommend "avoiding" this case?
use \DB as DB;at the top of your file, under the namespace declaration, and then you can continue to use DB without the backslash. But you'll have to do that for all core classes you use.
It looks like you're new here. If you want to get involved, click one of these buttons!