mirror of
https://github.com/php/presentations.git
synced 2026-03-24 07:32:11 +01:00
11 lines
331 B
PHP
11 lines
331 B
PHP
<?php
|
|
// Create ip2country view on the ip_ranges/country_data join
|
|
$db->query("CREATE VIEW ip2country AS
|
|
SELECT * FROM ip_ranges
|
|
INNER JOIN country_data
|
|
ON ip_ranges.country_code=country_data.id");
|
|
|
|
// Simpler user-land query
|
|
$db->query("SELECT country_name FROM ip2country
|
|
WHERE {$ip_int} BETWEEN ip_start AND ip_end");
|
|
?>
|