Select
1 2 3 4 5 | ->select('col1','col2')->select(array('col1','col2'))->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating')) ->addSelect('col3','col4')->distinct() // distinct select |
From
1 2 3 | ->from('table')->from(DB::raw('table, (select @n :=0) dummy'))->from(DB::raw("({$subQuery->toSql()}) T ")->mergeBindings($subQuery->getQuery()) |
Where
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | $detail = Detail::where("id","!=",50)->get();// Any of the following may be used as the second parameter (and use the third param for the value)// =, <, >, <=, >=, <>, !=, LIKE, NOT LIKE, BETWEEN, ILIKE$detail = Detail::where(function ($query) { $query->where('a', '=', 1) ->orWhere('b', '=', 1);})->get();$detail = Detail::whereRaw('age > ? and votes = 100', array(25))->get();$detail = Detail::whereRaw(DB::raw("id in (select detail_id from students GROUP BY students.detail_id)"))->get();$detail = Detail::whereExists(function($query){ $query->select(DB::raw(1)) ->from('students') ->whereRaw('students.detail_id = details.id') ->groupBy('students.detail_id') ->havingRaw("COUNT(*) > 0"); |