michaeldrennen/Geonames

backslash problem

Closed this issue · 2 comments

Hi,
Great plugin....

I found a problem after running this command:

php artisan geonames:install --country=CR --language=en

It fails at some point with this:

Inserting via LOAD DATA INFILE: D:\Web Development\laravel\timezonedb\storage\geonames\iso-languagecodes.txt
SQLSTATE[HY000]: General error: 7890 Can't find file 'D:Web Developmentlaravel  imezonedbstoragegeonamesiso-languagecod'.

I am developing on my Windows computer, so path file has backslash, these causes problems while running the following query:

$query = "LOAD DATA LOCAL INFILE '" . $localFilePath . "'
    INTO TABLE " . self::TABLE_WORKING . " IGNORE 1 LINES
        (   iso_639_3, 
            iso_639_2,
            iso_639_1, 
            language_name,          
            @created_at, 
            @updated_at)
    SET created_at=NOW(),updated_at=null";

I fixed it by adding the following line

$localFilePath = str_replace("\\", "\/", $localFilePath); <<<!! 
        $query = "LOAD DATA LOCAL INFILE '" . $localFilePath . "'......

I was lazy to find where was $localFilePath parameter pass in the code, so I just fixed it before it creates the query.

Sorry for the incredible delay.

That really is peculiar.
In my code that generates the path to the file on your local machine I use the PHP constant DIRECTORY_SEPARATOR which should avoid this problem altogether.

I've made a bunch of changes to the library, so perhaps try to run it again and let me know what happens.