Commit eac330f7 authored by Jeffrey van Hal's avatar Jeffrey van Hal Committed by Alexander Butenko

Update MysqliDb.php (#655)

* Update MysqliDb.php

Added option for LOAD DATA LOCAL

* Update readme.
parent 97f20c23
......@@ -1056,9 +1056,12 @@ class MysqliDb
// Add 1 more slash to every slash so maria will interpret it as a path
$importFile = str_replace("\\", "\\\\", $importFile);
// Switch between LOAD DATA and LOAD DATA LOCAL
$loadDataLocal = isset($settings["loadDataLocal"]) ? 'LOCAL' : '';
// Build SQL Syntax
$sqlSyntax = sprintf('LOAD DATA INFILE \'%s\' INTO TABLE %s',
$importFile, $table);
$sqlSyntax = sprintf('LOAD DATA %s INFILE \'%s\' INTO TABLE %s',
$loadDataLocal, $importFile, $table);
// FIELDS
$sqlSyntax .= sprintf(' FIELDS TERMINATED BY \'%s\'', $settings["fieldChar"]);
......
......@@ -301,6 +301,14 @@ Attach them using
```php
$options = Array("fieldChar" => ';', "lineChar" => '\r\n', "linesToIgnore" => 1);
$db->loadData("users", "/home/john/file.csv", $options);
// LOAD DATA ...
```
You can specify to **use LOCAL DATA** instead of **DATA**:
```php
$options = Array("fieldChar" => ';', "lineChar" => '\r\n', "linesToIgnore" => 1, "loadDataLocal" => true);
$db->loadData("users", "/home/john/file.csv", $options);
// LOAD DATA LOCAL ...
```
### Insert XML
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment