function uc_ip2country_install in IP-based Determination of a Visitor's Country 5
Implementation of hook_install().
Creates database tables needed by this module.
File
- ./
uc_ip2country.install, line 10
Code
function uc_ip2country_install() {
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
db_query("CREATE TABLE IF NOT EXISTS {ip2country} (\n ip2country_id int unsigned NOT NULL auto_increment,\n country char(3) NOT NULL,\n registry char(10) NOT NULL,\n ip_range_first bigint NOT NULL,\n ip_range_last bigint NOT NULL,\n ip_range_date datetime NOT NULL,\n ip_range_length int NOT NULL,\n PRIMARY KEY (ip2country_id),\n KEY (country, registry)\n ) /*!40100 DEFAULT CHARACTER SET UTF8 */");
break;
case 'pgsql':
// pgsql case NOT TESTED !
db_query("CREATE TABLE IF NOT EXISTS {ip2country} (\n ip2country_id serial NOT NULL,\n country char(3) NOT NULL,\n registry char(10) NOT NULL,\n ip_range_first bigint NOT NULL,\n ip_range_last bigint NOT NULL,\n ip_range_date datetime NOT NULL,\n ip_range_length int NOT NULL,\n PRIMARY KEY (ip2country_id)\n )");
db_query("CREATE INDEX {ip2country}_index ON {ip2country} (country, registry)");
break;
}
/* Populate the database */
ip2country_update_database();
}