1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
-
- namespace app\admin\model\system;
-
- use core\basic\Model;
-
- class CityModel extends Model{
-
- public function getAllList(){
- return parent::table('ay_city')->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;
-
- }
-
-
- public function modCity($id, $data){
- return parent::table('ay_city')->where("id='$id'")->update($data);
- }
-
- }
|