Reputation: 2555
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('table_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...
Upvotes: 0
Views: 886
Reputation: 5644
Edit:
$result = DB::select('*', array('original_column', 'alias'))->from('table_name')->execute()->current();
Upvotes: 2