php - How to count number of times a date has been used? -
how can count how many times date in table column using php , mysql?
i trying figure out way limit amount of dates can used rows
for example:
1 1 0000-00-00 2 yes 2013-10-06 20:07:17 2013-10-06 20:07:17 2 1 0000-00-00 4 yes 1 2013-10-06 20:19:31 2013-10-06 20:19:31 3 1 2013-10-15 2 yes 1 2013-10-06 20:22:14 2013-10-06 20:22:14 4 1 2013-10-30 3 yes 1 2013-10-06 21:07:28 2013-10-06 21:07:28
i want return error if 2013-10-30 has been used 5 times.
i using laravel 4 , saving data using model
if (<<<<code goes here???>>>>>){ return redirect::to('')->witherrors($full)->withinput(); } $schedule->userid = $user->id; $schedule->date = $dateformat; $schedule->block = $input['timeslot']; $schedule->status = "1"; $schedule->save();
you this:
schedule::where('timeslot', '=', $date)->count()
in addition, if piece of code used here , there create query scope can call in fashion schedule::countfortimeslot($date) anywhere or part of more complex query on top of model.
Comments
Post a Comment