Laravel queries - select entries conditionally -
i have query entries in database may have end
date set zero. how can following query - want select events where:
a) start date before today, end date set 0 (0000-00-00 00:00:00
)
and
b) start date and end date after today
all i've got far select start date after today:
$eventslist = db::table('events') ->where('start', '>', carbon::now()) ->get();
but misses started yesterday don't have end date set.
edit: have added query orwhere
clause, orwhere
causes return no results:
$eventslist = db::table('events') ->where('start', '>', carbon::now()) ->orwhere(function($query) { $query->where('start', '<', carbon::now()) ->where('end', '=', '0000-00-00 00:00:00'); }) ->get();
i guess looking this:
db::table('events') ->where(function($query) { $query->where('start', '>', carbon::now()) ->where('end', '>', carbon::now()) } ->orwhere(function($query) { $query->where('start', '<', carbon::now()) ->where('end', '=', '0000-00-00 00:00:00'); }) ->get();
Comments
Post a Comment