how to make query with substr in eloquent (laravel 4)? -


i have query:

select substr(id,1,4) id meteo.a2012 group substr(id,1,4) 

i want take first 4 numbers id row, i'm trying in eloquent, how do?

thanks.

you need use raw expressions can use special functions that.

model::select(db::raw('substr(id, 1, 4) id'))->groupby(db::raw('substr(id, 1, 4)'))->get(); 

where model eloquent model want run query on.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -