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 ...@@ -1056,9 +1056,12 @@ class MysqliDb
// Add 1 more slash to every slash so maria will interpret it as a path // Add 1 more slash to every slash so maria will interpret it as a path
$importFile = str_replace("\\", "\\\\", $importFile); $importFile = str_replace("\\", "\\\\", $importFile);
// Switch between LOAD DATA and LOAD DATA LOCAL
$loadDataLocal = isset($settings["loadDataLocal"]) ? 'LOCAL' : '';
// Build SQL Syntax // Build SQL Syntax
$sqlSyntax = sprintf('LOAD DATA INFILE \'%s\' INTO TABLE %s', $sqlSyntax = sprintf('LOAD DATA %s INFILE \'%s\' INTO TABLE %s',
$importFile, $table); $loadDataLocal, $importFile, $table);
// FIELDS // FIELDS
$sqlSyntax .= sprintf(' FIELDS TERMINATED BY \'%s\'', $settings["fieldChar"]); $sqlSyntax .= sprintf(' FIELDS TERMINATED BY \'%s\'', $settings["fieldChar"]);
......
...@@ -301,6 +301,14 @@ Attach them using ...@@ -301,6 +301,14 @@ Attach them using
```php ```php
$options = Array("fieldChar" => ';', "lineChar" => '\r\n', "linesToIgnore" => 1); $options = Array("fieldChar" => ';', "lineChar" => '\r\n', "linesToIgnore" => 1);
$db->loadData("users", "/home/john/file.csv", $options); $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 ### 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