Template.gallery.rendered = function(){
this.$('#grid-container').sortable({
stop: function(e, ui) {
el = ui.item.get(0)
before = ui.item.prev().get(0)
after = ui.item.next().get(0)
if(!before) {
newRank = Blaze.getData(after).rank - 1
} else if(!after) {
newRank = Blaze.getData(before).rank + 1
} else {
newRank = (Blaze.getData(after).rank + Blaze.getData(before).rank)/2
}
Images.update({_id: Blaze.getData(el)._id}, {$set: {rank: newRank}})
}
})
}
Template.gallery.helpers({
'getCurrentCategory': function() {
return Template.instance().currentcategory.get();
},
'images': function (currentcategory) {
if(currentcategory == 'all' || !currentcategory){
return Images.find({},{sort: {rank: 1}});
}
return Images.find({category:currentcategory});
}
});
答案 0 :(得分:1)
NOT IN
不允许空值,因此如果结果具有空值,则不会给出结果。
用这个:
SELECT DISTINCT category_id,name
FROM ek_category_description
WHERE category_id NOT EXISTS( SELECT DISTINCT parent_id FROM ek_category)
AND name LIKE '$searchvalue%'
即使使用空值,NOT EXISTS
也会给出结果。
<>
是一个单数运算符NOT
,因此使用NOT IN
效果会更好。
答案 1 :(得分:0)
使用NOT IN
SELECT DISTINCT category_id,name
FROM ek_category_description
WHERE category_id NOT IN( SELECT DISTINCT parent_id FROM ek_category)
AND name LIKE '$searchvalue%'