public function ip2location($ip) { $dao = new Ym_Dao('ip2location'); $where = "WHERE `ip_from` < {$ip} ORDER BY ip_from DESC LIMIT 1"; $sql = "SELECT `city_name` FROM `ip2location_db24` " . $where; $result = $dao->queryScalar($sql); $dao->selectDb('default'); return $result; }