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