lundi 22 février 2016

Laravel query not giving results through query builder

I have a query in Laravel query builder like this

$sql = $this
    ->database
    ->table('table1')
    ->join('table2', function ($join) {
        $join
            ->on('table1.uid', '=', 'table2.uid')
            ->where(function ($query) {
                $query
                    ->where('table1.key', '=', "'balance'")
                    ->where('table1.value', '=', "'0'");
            })
            ->orWhere(function ($query) {
                $query
                    ->where('table1.updated_at', '<=', "'$this->date'")
                    ->where('key', '=', "'balance'")
                    ->where('value', '=', "'1'");
            });
    })
    ->where('table2.balance_amount', '<=', 10000)
    ->join('table3', 'table3.uid', '=', 'table2.uid')
    ->get();

The issue is this query isn't giving any results when running through query builder , but if I execute the raw query which I am getting through toSql();, it is giving results. What might have gone wrong here ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/21bqLUl
via IFTTT

Aucun commentaire:

Enregistrer un commentaire