开发者

Kohana Database column aliasing, just one or two leaving the rest

Is there a way to alias a column or two and leave the rest intact using Database module.

# TAKING THIS EXAMPLE
$result = DB::select(array('longcolumnname1', 'col1'), array('longcolumnname2', 'aliascol2'))->from('tabl开发者_运维问答e_name')->execute()->current();

# AND TURNING IT INTO SOMETHING THIS... WITH THE '*'
$result = DB::select(array('longcolumnname1', 'col1'), array('longcolumnname2', '*'))->from('table_name')->execute()->current();

My main reason is that I'm doing a left join that sometimes returns empty, my id is being overwritten in the results and I'd hate to have to break down every column needed just to fix this result id issue... Is there an easy way... or am I just being lazy...


Edit:

$result = DB::select('*', array('original_column', 'alias'))->from('table_name')->execute()->current();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜