harish_sng
harish_sng

Reputation: 435

fetching null value in php framework, laravel query builder

I need laravel query builder to fetch '' as gdate to do union of another query.

example below:

$unionquery = DB::table('mt_task_category')
->whereIn('role_id', [1])
->select('null as gdate', 'null as user_id', 
         'category_id', 'category_name', 
         'null AS timeSum', 'null AS gdfullname', 
         'null AS id', 'null AS pmfullname', 'null AS role_name');

Upvotes: 0

Views: 66

Answers (1)

linktoahref
linktoahref

Reputation: 7992

You could make use of DB::raw()

$unionquery = DB::table('mt_task_category')
                ->select(DB::raw('null AS gdate', 'null AS user_id', 
                        'category_id', 'category_name', 
                        'null AS timeSum' , 'null AS gdfullname', 
                        'null AS id', 'null AS pmfullname', 
                        'null AS role_name'));
                ->whereIn('role_id', [1])
                ->get();

Upvotes: 1

Related Questions