In Kohana if I want to select fields 'id', and 'username' I do it this way:
$record = DB::select('id', 'username')
->from('users')
->where('id', '=', 1)
->as_object()
->execute();
But how to do it if the list of fields I need to select is in开发者_Go百科 an array, like this:
$fields = array('id', 'username');
How to use DB::select in this situation?
You are looking for DB::select_array()
.
You can also use $record = call_user_func_array('DB::select', $fields)
and then continue building the query; it might be ugly but it also works :)
精彩评论