我有一个解析问题,我希望得到所有具有特定订阅的人,但不是那些拥有其他类型订阅的人。订阅存储在订阅列的订阅表中的逗号描述列表中。这是我到目前为止的代码:
$includeQuery = [];
foreach ($includeSegment as $include) {
$singleQuery = ['subscriptions','like', '%'.$include.'%', 'or'];
array_push($includeQuery, $singleQuery);
}
$excludeQuery = [];
foreach ($excludeSegment as $exclude) {
$singleQuery = ['subscriptions', 'not like', '%'.$exclude.'%', 'or'];
array_push($excludeQuery, $singleQuery);
}
$included = Subscription::where($excludeQuery)->where($includeQuery)->get();
我收到了回复的结果,但其中一些已经排除了订阅。
答案 0 :(得分:0)
使用whereIn和whereNotIn代替:
订阅::其中($ includeSegment) - > whereNotIn($ excludeSegment) - >得到();
那么一旦它们是字符串数组
,你也不需要迭代它们答案 1 :(得分:0)
上面代码的问题在于我所拥有的布尔参数"或"而不是"和"。因此,只有当特定用户的所有订阅都存在时,才会抛出记录。这是更新的代码:
17/09/18 13:26:43 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Traceback (most recent call last):
File "/Users/opringle/Documents/Repos/finn/Magellan/src/no_spark_predict.py", line 58, in <module>
featurePipeline.serializeToBundle("jar:file:/tmp/pyspark.example.zip")
AttributeError: 'Pipeline' object has no attribute 'serializeToBundle'