开发者

Kohana database select, list of fields

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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜