Framework: [Request] Support for selectRaw() in Eloquent/Query Builder

Created on 12 Dec 2013  Â·  4Comments  Â·  Source: laravel/framework

Similar to whereRaw() I'd welcome an option to set the value for SELECT manually.

What I currently try to achieve is multiple SUM()s in one query.

The query builder has a sum() method, but this gives only one result and I would have to do almost the same query multiple times.

Something like DB::select('SUM(x) as x', 'SUM(y) as y') unfortunately does not work, because the select values get surrounded by backticks.

Most helpful comment

Done.

All 4 comments

To be fair, I didn't realise I could use DB::select(DB::raw('…')), but maybe a selectRaw() would be easier/shorter. But it's definitely not urgent.

Maybe the raw thing should be in the magic method instead of having to define a raw variant of each grammar component.

Good point.

Done.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jackmu95 picture jackmu95  Â·  3Comments

felixsanz picture felixsanz  Â·  3Comments

Fuzzyma picture Fuzzyma  Â·  3Comments

YannPl picture YannPl  Â·  3Comments

iivanov2 picture iivanov2  Â·  3Comments