Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 4.432 |
Changes | 0 |
1 | <?php |
||
39 | 2 | public function loadData(string $table, string $fname, array $fields, string $mode): string |
|
40 | { |
||
41 | 2 | if (substr(gethostbyname($this->conn->getHost()), 0, 3) !== '127') { |
|
42 | 1 | throw new NeuralyzerException('SQL Server must be on the same host than PHP'); |
|
43 | } |
||
44 | |||
45 | 1 | $sql ="BULK INSERT {$table} FROM '{$fname}' WITH ( |
|
46 | 1 | FIELDTERMINATOR = '|', DATAFILETYPE = 'widechar', ROWTERMINATOR = '" . PHP_EOL . "' |
|
47 | )"; |
||
48 | |||
49 | 1 | if ($this->pretend === false) { |
|
50 | if ($mode === 'update') { |
||
51 | $this->conn->query("TRUNCATE TABLE {$table}"); |
||
52 | } |
||
53 | |||
54 | $this->conn->query($sql); |
||
55 | } |
||
56 | |||
57 | 1 | return $sql; |
|
58 | } |
||
60 |