/ Published in: PHP
Esto es para obtener los codigos de paises desde geonames.org y almacenarlos en una tabla. Se iso bajo CodeIgniter.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
class Welcome { function obtener_codigos_de_paises() { $this->db->where('iso', ''); $query = $this->db->get('country'); foreach ($query->result() as $row) { if ($row->name == 'N/A' || $row->name == 'Otro') continue; $country = urlencode(str_replace(array('á', 'é', 'Ã', 'ó', 'ú', 'ñ'), array('a', 'e', 'i', 'o', 'u', 'n'), $row->name)); $ws_url = "http://api.geonames.org/searchJSON?maxRows=10&q=$country&username=demo&lang=es"; $this->db->set('iso', $data->geonames[0]->countryCode); $this->db->where('COUNTRY_ID', $row->COUNTRY_ID); $this->db->update('country'); } } } }