select(null)->from('geoip', null)->where('geoip.begin_ip <= inet_to_bigint(?)', (string)$ip) ->where('geoip.end_ip >= inet_to_bigint(?)', (string)$ip) ->limit(1) ->join('geonames', 'geonames.country = geoip.country', array( 'geonames.minlon', 'geonames.minlat', 'geonames.maxlon', 'geonames.maxlat' )); try { $stmt = $db->query($select); $row = $db->query($select)->fetch(); } catch (Exception $e) { $row = null; } if (!$row) { $row = Zend_Controller_Front::getInstance()->getParam('defaultloc'); } return array_map(function($elem) { return (float)$elem;},$row); } }