Php 从表中获取空值

Php 从表中获取空值,php,laravel,postgresql,laravel-5,Php,Laravel,Postgresql,Laravel 5,我想从表中的“category_type”字段中获取[null]、空白或空格的值 我想获取category类型中的[null]、空白、'Uncategorized'或空格。 现在我只能得到空值。也需要得到空值。如何在laravel查询的postgres db中也得到空值字段 我已经创建了变量$category=[] if(in_array('Uncategorized',$category)){ $category[]=''; $category[]=

我想从表中的“category_type”字段中获取[null]、空白或空格的值 我想获取category类型中的[null]、空白、'Uncategorized'或空格。 现在我只能得到空值。也需要得到空值。如何在laravel查询的postgres db中也得到空值字段

我已经创建了变量
$category=[]

if(in_array('Uncategorized',$category)){
          $category[]='';    
        $category[]='-';                  
        $category[]=' ';                  
        $category[]=null;                 
     }
 $table=DB::('category')->where('category.category_type',$category)->pluck('name')->toArray();

您可以添加
whereNull()
以检查空值,并添加
其中
以检查值数组:

if(in_array('Uncategorized',$category)){
        $category[]='';    
        $category[]='-';                  
        $category[]=' ';                                   
}

$table = DB::('category')->whereNull('category.category_type')
           ->whereIn('category.category_type', $category)
           ->pluck('name')
           ->toArray();

请尝试
where()
whereNull
。此主题可能有帮助:
$table = DB::('category')->whereNull('category.category_type')
           ->orWhereIn('category.category_type', $category)
           ->pluck('name')
           ->toArray();