Conditions | 4 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
42 | public function loadData( |
||
43 | string $table, |
||
44 | string $filename, |
||
45 | array $fields, |
||
46 | string $mode |
||
47 | ): string { |
||
48 | if (substr(gethostbyname($this->conn->getHost()), 0, 3) !== '127') { |
||
49 | throw new NeuralizerException('SQL Server must be on the same host than PHP'); |
||
50 | } |
||
51 | |||
52 | $sql ="BULK INSERT {$table} FROM '{$filename}' WITH ( |
||
53 | FIELDTERMINATOR = '|', DATAFILETYPE = 'widechar', ROWTERMINATOR = '" . PHP_EOL . "' |
||
54 | )"; |
||
55 | |||
56 | if ($this->pretend === false) { |
||
57 | if ($mode === 'update') { |
||
58 | $this->conn->query("TRUNCATE TABLE {$table}"); |
||
59 | } |
||
60 | |||
61 | $this->conn->query($sql); |
||
62 | } |
||
63 | |||
64 | return $sql; |
||
65 | } |
||
66 | } |
||
67 |