PHP Classes

geozonedb: Get world geographic data from GeoNames into MySQL

Recommend this page to a friend!
  Info   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 670 All time: 4,797 This week: 339Up
Version License PHP version Categories
geozonedb 0.4GNU General Publi...5PHP 5, Databases, Web services, Geogr...
Description Author

This class can get world geographic data from GeoNames into MySQL.

It can retrieve geographic data files about countries of the world from the GeoNames site and populates a MySQL database for easier lookup.

The class can create the necessary MySQL tables and fill them with country data elements like names, codes, capital names, location coordinates, city names, postal codes, etc..

Innovation Award
PHP Programming Innovation award nominee
June 2011
Number 4

Prize: One subscription to the PDF edition of the PHP Architect magazine
GeoNames is site that aggregates information of all regions around the world. That information may be searched in the site or via a Web service.

However, if you need to perform intensive queries on the available information, it would be faster if you query it locally. The site also provides dumps of their database, so you can retrieve and use it locally in any other site.

This class can parse the Geonames database dump files and import it into a local MySQL database to make it easier to query the Geonames information in a much faster way.

Manuel Lemos
Picture of Virgilio lino
  Performance   Level  
Name: Virgilio lino <contact>
Classes: 8 packages by
Country: Italy Italy
Age: 43
All time rank: 158564 in Italy Italy
Week rank: 197 Up7 in Italy Italy Up
Innovation award
Innovation award
Nominee: 5x

Winner: 2x

Copyright Virgilio Lino 2011 Geozonedb.
Based on data taken from
The framework and sql files are released under dual license,
Creative Commons Attribution 3.0 License and gpl license 2.

GeoZoneDB is an opensource project to load geozone data into sql
files, ready to download if you don't want to lose time. Database
has been conceived to be as fast as possible to retrieve data from
every Community, State, Country of the world, with population, postal
code, etc.

GeoZoneDB 0.5
geozonedb.php - world data extraction framework
geozonesearch.php - this is the only class you need if you plan to integrate geodata in your software or site.
                    An example of autosuggest is on file index.php please read comments on beginning of the file
                    I'm building a new dump in english, you'll just need to download it and include some files
                    to have all data in your software. I highly recommend to create a database just for geographical
                    data as it together with your database tables, it could slowdown everything. 
Read the instructions for GeoZoneDB0.4 as are ok for 0.5
Please let me know if you like it to send me suggestions, or if you want TO HELP ME!!!!
I'm searching for every skill, even if you are not a programmer i need someone to create a dump of every world language,
i need some one to put files on my site, etc

GeoZoneDB 0.4
What is GeoZoneDB 

You may just download(its still not updated to version 0.4):
geozonedb_dump_data.tar.bz2 wich is an sql file, if you import it in your database you'll have
an optimized database with all the world zones, 2 country tables, and more than one hundred
zones comunity tables

To create a database with new 0.4 version do what follows:
0. Create a database with for example phpmyadmin or you may use an old database
To setup:
1. includes/configure.php
DB_SERVER                   :   the server name: usually it's fine to live "localhost"
DB_SERVER_USERNAME          :   the username      : the username to access the db
DB_SERVER_PASSWORD          :   the password of the user to access the db
DB_DATABASE                 :   the name of the database

There is no need to create the tables in the database, tables will be automatically generated
to populate the countries data:
$geo=new geoZoneDB();
$geo->setLocale('IT');  // if setted data will not be loaded in english but in the language indicated

to populate the zones data:
$geo=new geoZoneDB();



I need help to optimize the database, i plan to integrate the framework
with Sphinx indexes.
I need help to improve the php framework to import data.
I need help to build a multilevel set of combos to navigate throw
I plan to build on next release an autosuggest system instead of
multilevel set of combos.
please contact me at


Version 0.4 ----------------------------------------------------------------------------------------------------
I've done some OO evolution of the code, on this version i'm gonna try MYsql fulltext search capabilities,
even if benchmarks around on the net tell mysql fullsearch is slow, i've done some tries and i think it's ok,
i get same benchmark as with innodb but without advanced capabilities on IR applied to index.
-result ordered by ranking!

Version 0.3 ----------------------------------------------------------------------------------------------------
I've changed the structure of the every zones table, i'ved removed the ISOnumeric field, it's the field to identify
the country, but, as the information is inserted on the table named by the country code, i think it could be enough
to take the table number, however I've created a ZoneToCountry table with two fields, it will be usefull to identify
the country a zone comes from.
The second most important change is that Zone_ID will be a unique ID among all the zone tables, so the extraction framework
must assing a unique id to every zone row, i mean unique not just inside the table on where it's but, unique among every
zone table, in these way we have a 32bit, the first target to apply the sphinx indexing capabilities. We plan to build
a view with all the zone tables and to index it with the open source indexing server. 

  Files folder image Files  
File Role Description
Plain text file geozonedb.php Class main class
Accessible without login Plain text file readme Doc. instructions
Accessible without login Plain text file engine.php Example library used by main class put in includes directory
Accessible without login Plain text file includes_configure.php Conf. put on includes directory
Accessible without login Plain text file includes_geozonedb.php Aux. put on includes directory
Plain text file geozonesearch.php Class class for interface to use on your application
Accessible without login Plain text file index.php Appl. example of usage

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:4,797
This week:339Up
For more information send a message to info at phpclasses dot org.