作者 Karson
提交者 Gitee

!245 修复后台分类调用PID为0时无法调用顶级分类

Merge pull request !245 from simon429/master
@@ -221,16 +221,15 @@ class Ajax extends Backend @@ -221,16 +221,15 @@ class Ajax extends Backend
221 $pid = $this->request->get('pid'); 221 $pid = $this->request->get('pid');
222 $where = ['status' => 'normal']; 222 $where = ['status' => 'normal'];
223 $categorylist = null; 223 $categorylist = null;
224 - if ($pid !== '') { 224 + if ($pid || $pid === '0') {
  225 + $where['pid'] = $pid;
  226 + }
225 if ($type) { 227 if ($type) {
226 $where['type'] = $type; 228 $where['type'] = $type;
227 } 229 }
228 - if ($pid) {  
229 - $where['pid'] = $pid;  
230 - }  
231 230
232 $categorylist = Db::name('category')->where($where)->field('id as value,name')->order('weigh desc,id desc')->select(); 231 $categorylist = Db::name('category')->where($where)->field('id as value,name')->order('weigh desc,id desc')->select();
233 - } 232 +
234 $this->success('', null, $categorylist); 233 $this->success('', null, $categorylist);
235 } 234 }
236 235