where('status=1')->order('sorting asc')->select(1); } // 获取分站列表 public function getList($pid=0){ $field = array( 'a.*', "(select count(b.id) from ay_city b where b.pid=a.id) as count" ); $where['pid']=$pid; $result = parent::table('ay_city a')->field($field)->where($where)->where('id!=381')->order('a.sorting asc')->select(); return $result; } // 检查分站 public function checkName($where){ return parent::table('ay_city')->field('title,etitle') ->where($where) ->find(); } // 添加分站 public function addCity($data){ return parent::table('ay_city')->insert($data); } // 查询分站 public function findCity($id){ return parent::table('ay_city')->where("id={$id}")->find(); } // 删除分站 public function delCity($id){ return parent::table('ay_city')->where("id='$id' OR pid='$id'")->delete(); } // 批量删除分站 public function delCityList($ids){ foreach($ids as $id){ $this->delCity($id); } return true; //return parent::table('ay_city')->delete($ids); } // 修改分站资料 public function modCity($id, $data){ return parent::table('ay_city')->where("id='$id'")->update($data); } public function etitleIsCf($name,$sort){ $row = parent::table('ay_city')->where("etitle='$name'")->find(); if(!empty($row)){ return $sort.$name; }else{ return $name; } } public function titleIsCf($name,$sort){ $row = parent::table('ay_city')->where("title='$name'")->find(); if(!empty($row)){ return $sort.$name; }else{ return $name; } } public function addRow($data){ return parent::table('ay_city')->insert($data); } public function getSortLast($pid=0){ $sorting = parent::table('ay_city')->order('id desc')->value('sorting'); return $sorting; } }