dimanche 3 janvier 2016

Lumen/Laravel query builder - BETWEEN

I'm attempting to convert this tradtional sql query to larvael/lumen query builder and running into brick walls.

$query = "SELECT a.id, a.name, a.cuisine, a.status, a.new, a.addressLine1, a.addressLine2, a.addressLine3, a.city, a.weekendot, a.weekendct, b.class
    FROM restaurants a, restaurants_class b
    WHERE a.class = b.id
    AND '$date' = CURRENT_DATE
    AND '$ntime' BETWEEN a.weekendot AND a.weekendct
    ORDER BY id DESC";

$date and $ntime are variables.

This is what I have so far;

$posts = DB::connection('web')
        ->table('restaurants')
        ->join('restaurants_class', 'restaurants.class', '=', 'restaurants_class.id')
        ->select('restaurants.*', 'restaurants_class.*')
        ->get();

The first AND statement is not getting anything from the DB

The second AND statement is comparing a var to two columns in the DB

Not sure how to implement the whereBetween



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire