/** * 更新学校 */ public function updateAction() { list($update, $add, $areaid, $typeid) = $this->getInput(array('update', 'add', 'areaid', 'typeid'), 'post'); foreach ($update as $id => $name) { $dm = new WindidSchoolDm(); $dm->setSchoolid($id)->setName($name)->setFirstChar($this->_getService()->getFirstChar($name)); $r = $this->_getDs()->updateSchool($dm); if ($r instanceof WindidError) { $this->showError('ADMIN:school.error.' . $r->getCode()); } } $addDms = array(); foreach ($add as $name) { $dm = new WindidSchoolDm(); $dm->setName($name)->setTypeid($typeid)->setAreaid($areaid)->setFirstChar($this->_getService()->getFirstChar($name)); $addDms[] = $dm; } $r = $this->_getDs()->batchAddSchool($addDms); if ($r instanceof WindidError) { $this->showError('ADMIN:school.error.' . $r->getCode()); } $this->showMessage('success', 'windid/schooldata/run?type=' . $typeid . '&areaid=' . $areaid); }
/** * 更新学校 */ public function updateAction() { list($update, $add, $areaid, $typeid) = $this->getInput(array('update', 'add', 'areaid', 'typeid'), 'post'); is_array($update) || ($update = array()); is_array($add) || ($add = array()); foreach ($update as $id => $name) { $dm = new WindidSchoolDm(); $dm->setSchoolid($id)->setName($name)->setFirstChar($this->_getDs()->getFirstChar($name)); $r = $this->_getDs()->updateSchool($dm); if ($r < 1) { $this->showError('WINDID:code.' . $r); } } if ($add) { $addDms = array(); foreach ($add as $name) { $dm = new WindidSchoolDm(); $dm->setName($name)->setTypeid($typeid)->setAreaid($areaid)->setFirstChar($this->_getDs()->getFirstChar($name)); $addDms[] = $dm; } $r = $this->_getDs()->batchAddSchool($addDms); if ($r < 1) { $this->showError('WINDID:code.' . $r); } } $this->showMessage('success', 'windidclient/schooldata/run?type=' . $typeid . '&areaid=' . $areaid); }
public function updateSchool(WindidSchoolDm $dm) { $params = array('id' => $dm->schoolid); return WindidApi::open('school/update', $params, $dm->getData()); }
protected function buildData($id, $type) { $url = 'http://api.pengyou.com/json.php?cb=__i_5&mod=school&act=selector&schooltype=' . $type . '&district=' . $id; $content = file_get_contents($url); preg_match('/{(.*)}/is', $content, $matches); $content = WindJson::decode($matches[0]); $result = $content['result']; preg_match_all('/javascript:choose_school\\((\\d+),\'(.*)\'\\);/iUs', $result, $matches); $addDms = array(); foreach ($matches[1] as $k => $v) { $dm = new WindidSchoolDm(); $dm->setName($matches[2][$k])->setTypeid($this->getSchoolType($type))->setAreaid($id)->setFirstChar($this->_getService()->getFirstChar($matches[2][$k])); $addDms[] = $dm; } return $this->_getSchoolDs()->batchAddSchool($addDms); }
public function updateAction() { $ids = $this->getInput('id', 'get'); list($name, $firstchar, $typeid, $areaid) = $this->getInput(array('name', 'first_char', 'typeid', 'areaid'), 'post'); Wind::import('WSRV:school.dm.WindidSchoolDm'); foreach ($name as $k => $id) { $dm = new WindidSchoolDm(); $dm->setSchoolid($id); isset($name[$k]) && $dm->setName($name[$k]); isset($firstchar[$k]) && $dm->setFirstChar($firstchar[$k]); isset($typeid[$k]) && $dm->setTypeid($typeid[$k]); isset($areaid[$k]) && $dm->setAreaid($areaid[$k]); $dms[] = $dm; } $result = $this->_getSchoolDs()->batchAddSchool($dms); $this->output(WindidUtility::result($result)); }
/** * 更新学校数据 * * @param WindidSchoolDm $schooldm * @return int */ public function updateSchool(WindidSchoolDm $schooldm) { if (true !== ($r = $schooldm->beforeUpdate())) { return $r; } return $this->_getDao()->updateSchool($schooldm->getSchoolid(), $schooldm->getData()); }