Php Laravel雄辩地使用null作为select上的列值?
如何在Laravel eloquent中使用null作为列值,就像在下面的查询中一样(下面的查询不起作用,其示例为空) 此处,空为凭证\u no”不起作用。如何在此查询中使用null。在列周围使用,这将强制laravel按原样传递列名:Php Laravel雄辩地使用null作为select上的列值?,php,sql,laravel-5,Php,Sql,Laravel 5,如何在Laravel eloquent中使用null作为列值,就像在下面的查询中一样(下面的查询不起作用,其示例为空) 此处,空为凭证\u no”不起作用。如何在此查询中使用null。在列周围使用,这将强制laravel按原样传递列名: $query = \DB::table('invoices as inv') ->leftjoin('customer as c', 'c.id', '=', 'inv.customer_id') ->select([
$query = \DB::table('invoices as inv')
->leftjoin('customer as c', 'c.id', '=', 'inv.customer_id')
->select([
'inv.id',
'inv.invoice_date',
'inv.invoice_no',
DB::raw('null as voucher_no'),
DB::raw('null as credit'),
]);
在列周围使用,这将强制laravel按原样传递列名:
$query = \DB::table('invoices as inv')
->leftjoin('customer as c', 'c.id', '=', 'inv.customer_id')
->select([
'inv.id',
'inv.invoice_date',
'inv.invoice_no',
DB::raw('null as voucher_no'),
DB::raw('null as credit'),
]);