心理咨询网
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

CityModel.php 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * 分站模型类
  4. */
  5. namespace app\admin\model\system;
  6. use core\basic\Model;
  7. class CityModel extends Model{
  8. // 获取分站列表 -- 前端缓存城市用
  9. public function getAllList(){
  10. return parent::table('ay_city')->where('status=1')->order('sorting asc')->select(1);
  11. }
  12. // 获取分站列表
  13. public function getList($pid=0){
  14. $field = array(
  15. 'a.*',
  16. "(select count(b.id) from ay_city b where b.pid=a.id) as count"
  17. );
  18. $where['pid']=$pid;
  19. $result = parent::table('ay_city a')->field($field)->where($where)->where('id!=381')->order('a.sorting asc')->select();
  20. return $result;
  21. }
  22. // 检查分站
  23. public function checkName($where){
  24. return parent::table('ay_city')->field('title,etitle')
  25. ->where($where)
  26. ->find();
  27. }
  28. // 添加分站
  29. public function addCity($data){
  30. return parent::table('ay_city')->insert($data);
  31. }
  32. // 查询分站
  33. public function findCity($id){
  34. return parent::table('ay_city')->where("id={$id}")->find();
  35. }
  36. // 删除分站
  37. public function delCity($id){
  38. return parent::table('ay_city')->where("id='$id' OR pid='$id'")->delete();
  39. }
  40. // 批量删除分站
  41. public function delCityList($ids){
  42. foreach($ids as $id){
  43. $this->delCity($id);
  44. }
  45. return true;
  46. //return parent::table('ay_city')->delete($ids);
  47. }
  48. // 修改分站资料
  49. public function modCity($id, $data){
  50. return parent::table('ay_city')->where("id='$id'")->update($data);
  51. }
  52. public function etitleIsCf($name,$sort){
  53. $row = parent::table('ay_city')->where("etitle='$name'")->find();
  54. if(!empty($row)){
  55. return $sort.$name;
  56. }else{
  57. return $name;
  58. }
  59. }
  60. public function titleIsCf($name,$sort){
  61. $row = parent::table('ay_city')->where("title='$name'")->find();
  62. if(!empty($row)){
  63. return $sort.$name;
  64. }else{
  65. return $name;
  66. }
  67. }
  68. public function addRow($data){
  69. return parent::table('ay_city')->insert($data);
  70. }
  71. public function getSortLast($pid=0){
  72. $sorting = parent::table('ay_city')->order('id desc')->value('sorting');
  73. return $sorting;
  74. }
  75. }