我有以下查询,我想知道这是否可以在laravel的querybuilder中使用:
SELECT * FROM table WHERE (column = value OR column = value2) AND column2 LIKE '%value3%'
答案 0 :(得分:10)
您的查询应如下所示:
DB::table('table')
->where(function($q) use ($value, $value2) {
$q->where('column', $value)
->orWhere('column', $value2);
})
->where('column2', 'like', '%'.%value3.'%')
->get();
如果您有多个值,可以将它们放入一个简单的数组中并使用whereIn()
:
DB::table('table')
->whereIn('column', $valuesArray)
->where('column2', 'like', '%'.%value3.'%')
->get();
答案 1 :(得分:1)
答案 2 :(得分:0)
您可以根据所需的查询
执行此操作var select = new ol.interaction.Select({
multi: true
});
var fnHandler = function (e) {
e.selected; // array of selected features
e.target; // select interaction
var feature = e.selected.filter(function (feature) {
// do some filtering to choose what feature do you want
})[0];
e.target.getFeatures().clear(); // unselect all features
e.target.getFeatures().push(feature); // select the feature you filtered
};
select.on('select', fnHandler);