public function pagegetregion() { $aJson = array(); $regionObj = new m_region(); $iPid = (int) $_REQUEST['parent_id']; $exce = (int) $_REQUEST['exce']; $aRegions = $regionObj->select(array("parent_id" => $iPid), '*', '', 'order by region_id asc')->items; if (empty($iPid)) { echo json_encode(array()); exit; } if ($aRegions) { foreach ($aRegions as $aRegion) { $r = array('region_id' => $aRegion['region_id'], 'region_name' => $aRegion['region_name']); $aJson[] = $r; } echo json_encode($aJson); } else { if ($exce) { $aRegions = $regionObj->select(array("parent_id" => $iPid), '*', '', 'order by region_id asc')->items; if (!empty($aRegions)) { $r = array('region_id' => $aRegions['region_id'], 'region_name' => $aRegions['region_name']); echo json_encode(array($r)); } else { echo json_encode(array()); } } else { echo json_encode(array()); } } }
public function create($data) { if (!$data['realname'] or !$data['membercardid']) { $this->setError(0, "缺少必要参数"); return false; } if (!$data['mid']) { if ($this->get("membercardid = '{$data['membercardid']}'")) { $this->setError(0, "会员卡卡号重复"); return false; } $this->set('lastdateline', 0); } if (is_array($data)) { foreach ($data as $key => $val) { if ($this->set($key, $val) === false) { $this->setError(0, "设置字段{$key}失败 " . $this->getError()); return false; } } } $regionObj = new m_region(); if ($data['prov_id']) { $rs = $regionObj->get("region_id = {$data['prov_id']}", 'region_name'); $this->set('prov_name', $rs['region_name']); } if ($data['city_id']) { $rs = $regionObj->get("region_id = {$data['city_id']}", 'region_name'); $this->set('city_name', $rs['region_name']); } $this->set('regdateymd', date('Y-m-d', $this->_time)); $this->set('regdateline', $this->_time); $rs = $this->save($data['mid']); if ($rs) { return $rs; } $this->setError(0, "保存数据失败" . $this->getError()); return false; }