Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Kohana数据库选择,字段列表_Php_Mysql_Kohana - Fatal编程技术网

Php Kohana数据库选择,字段列表

Php Kohana数据库选择,字段列表,php,mysql,kohana,Php,Mysql,Kohana,在Kohana中,如果我想选择字段“id”和“username”,我可以这样做: $record = DB::select('id', 'username') ->from('users') ->where('id', '=', 1) ->as_object() ->execute(); 但是,如果需要选择的字段

在Kohana中,如果我想选择字段“id”和“username”,我可以这样做:

$record = DB::select('id', 'username')
                    ->from('users')
                    ->where('id', '=', 1)
                    ->as_object()
                    ->execute();
但是,如果需要选择的字段列表位于一个数组中,该如何操作,如下所示:

$fields = array('id', 'username');

在这种情况下如何使用DB::select?

您正在寻找的是
DB::select_array()

您还可以使用
$record=call\u user\u func\u数组('DB::select',$fields)
,然后继续构建查询;这可能很难看,但也很管用:)