如何在Kohana选择列作为“另一个名字”

时间:2015-09-11 14:04:07

标签: kohana alias

我正在使用Kohana。我正在尝试选择一个列some name但是它给出了错误 - Table 'users AS U' doesn't exist 如何制作这个别名?

 $result = DB::select( 'users.firstname',
                       'users.lastname',
                        'U.firstname AS alt_firstname',
                                   
                       'U.lastname AS alt_lastname'
)
 ->from('mytable')
 ->join('table2', 'INNER')
                ->on('mytable.id', '=', DB::expr('table2.id'))
                ->join('users', 'INNER')
                ->on('users.id', '=', DB::expr('mytable.id'))
                ->join('users AS U', 'INNER')
                ->on('U.id', '=', DB::expr('table2.id'))
                ->execute();
        return $result;

1 个答案:

答案 0 :(得分:1)

$ query = DB :: select(array('username','u'),array('password','p')) - > from('users');

https://kohanaframework.org/3.3/guide/database/query/builder#select-as-column-aliases