【问题标题】:Using Laravel Fluent how can I exclude certain rows based on an array of strings?使用 Laravel Fluent 如何根据字符串数组排除某些行?
【发布时间】:2015-03-07 15:38:44
【问题描述】:

在我的控制器文件中,我有这个:

$standard_sets = ['A', 'B', 'C', 'D', 'E'];
$exclude_list = ['str1', 'str2', 'str3'];

我想根据排除数组排除某些行。像这样的:

$query->whereIn('cards.setCode', $standard_sets)
->exclude('cards.name', $exclude_list);

写这个的正确方法是什么?

【问题讨论】:

    标签: php laravel fluent


    【解决方案1】:

    whereNotIn()怎么样?

    $query->whereIn('cards.setCode', $standard_sets)
          ->whereNotIn('cards.name', $exclude_list);
    

    【讨论】:

    • 谢谢!你真棒。 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-28
    • 1970-01-01
    • 2014-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-17
    相关资源
    最近更新 更多