cityAction.php 1010 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. class cityClassAction extends Action
  3. {
  4. //数据源
  5. public function getdataAjax()
  6. {
  7. $id = $this->post('id');
  8. if(isempt($id))$id='1';
  9. $id = (int)$id;
  10. $dbs = m('city');
  11. $rows = $dbs->getrows('pid='.$id.'','*','`sort`,`id`');
  12. $patha = $dbs->getpath($id);
  13. $type = $dbs->getmou('type', $id);
  14. if(isempt($type))$type=-1;
  15. $ntype = (int)$type+1;
  16. if($ntype==0)$id = 0; //顶级
  17. return array(
  18. 'type' => $ntype,
  19. 'pid' => $id,
  20. 'rows' => $rows,
  21. 'path' => $patha,
  22. );
  23. }
  24. //删除
  25. public function deldataAjax()
  26. {
  27. $id = (int)$this->post('id','0');
  28. $to = m('city')->rows("`pid`='$id'");
  29. if($to>0)return returnerror('有'.$to.'条下级不能删除');
  30. m('city')->delete($id);
  31. return returnsuccess();
  32. }
  33. //从官网获取城市数据
  34. public function initdataAjax()
  35. {
  36. c('cache')->del('cityalldata');
  37. return m('city')->daorudata();
  38. }
  39. public function clearchaheAjax()
  40. {
  41. c('cache')->del('cityalldata');
  42. }
  43. }
粤ICP备19079148号