All In One Script
MENU

MySQL IN statement using Laravel

by 2:58:00 AM
undefined
MySQL IN statement using Laravel Im having the user filling checkboxes in my view for each year so that they can query based on selected years. The query is looking for a pH value between a minimum and maximum value. As you can see there can be a variety of different years selected. View @foreach($years as $year) {{ Form::checkbox('selectedYears[]', $year->year) }} {{ $year->year }} @endforeach In my controller i then have something like this: Controller $implodeYears = implode(', ',$input['selectedYears']); DB::select('SELECT samples.*, costumers.* FROM

Group by month producing error in laravel controller

by 2:55:00 AM
undefined
Group by month producing error in laravel controller I am trying to execute mysql query SELECT COUNT( * ) FROM `Mytable` WHERE `col1` = 'value' GROUP BY MONTH(Date_time) Laravel statement for the same is : DB::table('Mytable')->where('col1','value')->GroupBy(MONTH('Date_time'))->count(); As query is fine but getting error : Call to undefined function App\Http\Controllers\MONTH() Any suggestion will be helpful Best answer : Instead of: ->GroupBy(MONTH('Date_time')) try ->groupBy(DB::raw("MONTH('Date_time')")) as MONTH() is a mysql function, not laravel function. source :http://stackoverflow.com/questions/41460359/group-by-month-producing-error-in-laravel-controller

Instagram