FutureWeb
4 years ago

Load data in file

Posted 4 years ago by FutureWeb

can we do load data infile with laravel? I found this but it's not working:

     private function loadData($file)
     {

        $query = sprintf("LOAD DATA local INFILE '%s' INTO TABLE raw_data FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES", addslashes($file));

        return DB::connection()->getpdo()->exec($query);

    
    }

Please sign in or create an account to participate in this conversation.