Laravel 拉威尔3雄辩:寻找一个;其中“u嵌套()”;例子

Laravel 拉威尔3雄辩:寻找一个;其中“u嵌套()”;例子,laravel,eloquent,laravel-3,Laravel,Eloquent,Laravel 3,我有一个自定义验证规则,用于检查数据库是否为空。 我需要查找null或empty 拥有: $query = $this->db()->table($table); ... foreach( $null_columns as $col ) $query->where_null($col); 其结果类似于:SELECT*FROM t,其中col1=foo,col2为NULL 想要: 从t中选择*其中col1=blah和(col2='

我有一个自定义验证规则,用于检查数据库是否为空。
我需要查找nullempty

拥有:

    $query = $this->db()->table($table);
    ...
    foreach( $null_columns as $col )
            $query->where_null($col);
其结果类似于:
SELECT*FROM t,其中col1=foo,col2为NULL

想要:
从t中选择*其中col1=blah和(col2=''或col2为NULL)

问题:

    $query = $this->db()->table($table);
    ...
    foreach( $null_columns as $col )
            $query->where_null($col);
where-nested()
是作业的正确工具吗?
如果是这样,我真的很想看一个例子。

如果没有,那么什么是解决这个问题的好方法?

好吧,我最终让它以这种方式工作:

    $query = $this->db()->table($table);
    ...
    foreach( $null_columns as $col )
    {
        $query->where(function($q) use($col){
            $q->where($col,'=','');
            $q->or_where_null($col);
        });
    }

。。。但是如果可能的话,我仍然希望看到一个使用
where\u nested()
来实现这一点的示例。我一直很感激学习新的东西:)

好吧,我最终让它以这种方式工作:

    $query = $this->db()->table($table);
    ...
    foreach( $null_columns as $col )
    {
        $query->where(function($q) use($col){
            $q->where($col,'=','');
            $q->or_where_null($col);
        });
    }
。。。但是如果可能的话,我仍然希望看到一个使用
where\u nested()
来实现这一点的示例。我总是喜欢学习新东西:)