|
@@ -78,21 +78,21 @@ class Api
|
|
|
*
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function getInfo($area)
|
|
|
+ public function getInfo($area, $col = 'id')
|
|
|
{
|
|
|
if ($area) {
|
|
|
$area = explode(',', $area);
|
|
|
$result = array();
|
|
|
foreach ($area as $k => $v) {
|
|
|
if ($k == 0) {
|
|
|
- $result[$k] = $this->getName('province', $v, true);
|
|
|
+ $result[$k] = $this->getName('province', $v, true, $col);
|
|
|
} elseif ($k == 1) {
|
|
|
- $result[$k] = $this->getName('city', $v, true);
|
|
|
- if ($result[0]['name'] == $result[1]['name']) {
|
|
|
+ $result[$k] = $this->getName('city', $v, true, $col);
|
|
|
+ if ($col == 'id' && isset($result[1]['name']) && $result[0]['name'] == $result[1]['name']) {
|
|
|
unset($result[1]);
|
|
|
}
|
|
|
} elseif ($k == 2) {
|
|
|
- $result[$k] = $this->getName('county', $v, true);
|
|
|
+ $result[$k] = $this->getName('county', $v, true, $col);
|
|
|
}
|
|
|
}
|
|
|
return $result;
|
|
@@ -128,12 +128,12 @@ class Api
|
|
|
}
|
|
|
|
|
|
|
|
|
- private function getName($table, $id, $state = false)
|
|
|
+ private function getName($table, $value, $state = false, $col = 'id')
|
|
|
{
|
|
|
$name = '不限';
|
|
|
- if ($id > 0) {
|
|
|
- $data = Dever::db('area/' . $table)->one($id);
|
|
|
-
|
|
|
+ if (($col == 'id' && $value > 0) || ($col != 'id' && $value)) {
|
|
|
+ $where[$col] = $value;
|
|
|
+ $data = Dever::db('area/' . $table)->one($where);
|
|
|
if ($state) {
|
|
|
return $data;
|
|
|
}
|