@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC |
| 136 | 136 | ]; |
| 137 | 137 | try { |
| 138 | - $this->db = new PDO("mysql:host=".$this->config["db_host"].";port=".$this->config["db_port"].";dbname=" . $this->config["db_name"], |
|
| 138 | + $this->db = new PDO("mysql:host=".$this->config["db_host"].";port=".$this->config["db_port"].";dbname=".$this->config["db_name"], |
|
| 139 | 139 | $this->config["db_username"], $this->config["db_password"], $db_options); |
| 140 | 140 | } |
| 141 | 141 | catch (PDOException $e) { |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $this->column_fixes = []; |
| 243 | 243 | $sql_keys = []; |
| 244 | 244 | $sql_values = []; |
| 245 | - foreach($this->dbfColumns as $column) { |
|
| 245 | + foreach ($this->dbfColumns as $column) { |
|
| 246 | 246 | $sql_keys[] = "`".$column["name"]."`"; |
| 247 | 247 | $sql_values[] = ":".$column["name"]; |
| 248 | 248 | if (in_array($column["type"], ["F", "N", "I", "Y", "0"])) { |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | $this->writeLog("\nCalculate column types for table <yellow>".$this->dbfHeaders["table"]."<default>"); |
| 315 | 315 | $lines = []; |
| 316 | 316 | foreach ($this->dbfColumns as $column) { |
| 317 | - if (in_array($column["type"], ["F", "N", "I", "Y", "0"])) { |
|
| 317 | + if (in_array($column["type"], ["F", "N", "I", "Y", "0"])) { |
|
| 318 | 318 | $result = $this->column_fixes[$column["name"]]; |
| 319 | 319 | $unsigned = !($result["min"] < 0); |
| 320 | 320 | if ($unsigned) { |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | "table" => $this->dbfHeaders["table"], |
| 375 | 375 | "column" => $this->config["key_field"]]); |
| 376 | 376 | if ($result->rowCount()) { |
| 377 | - $this->db->exec("ALTER TABLE `" . $this->dbfHeaders["table"] . "` ADD INDEX(`" . $this->config["key_field"] . "`)"); |
|
| 377 | + $this->db->exec("ALTER TABLE `".$this->dbfHeaders["table"]."` ADD INDEX(`".$this->config["key_field"]."`)"); |
|
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | } |
@@ -384,13 +384,11 @@ discard block |
||
| 384 | 384 | if ($this->percent <> !$percent) { |
| 385 | 385 | $this->percent = $percent; |
| 386 | 386 | $part1 = (($percent < 25) ? |
| 387 | - $this->colors["white"].str_repeat("H", $percent).$this->colors["default"].$this->colors["red"].str_repeat(".", 25 - $percent) : |
|
| 388 | - $this->colors["white"].str_repeat("H", 25)).$this->colors["default"]; |
|
| 387 | + $this->colors["white"].str_repeat("H", $percent).$this->colors["default"].$this->colors["red"].str_repeat(".", 25 - $percent) : $this->colors["white"].str_repeat("H", 25)).$this->colors["default"]; |
|
| 389 | 388 | if ($percent > 25) { |
| 390 | 389 | $percent = $percent - 25; |
| 391 | 390 | $part2 = (($percent < 50) ? |
| 392 | - $this->colors["white"].str_repeat("H", $percent).$this->colors["default"].$this->colors["red"].str_repeat(".", 25 - $percent) : |
|
| 393 | - $this->colors["white"].str_repeat("H", 25)).$this->colors["default"]; |
|
| 391 | + $this->colors["white"].str_repeat("H", $percent).$this->colors["default"].$this->colors["red"].str_repeat(".", 25 - $percent) : $this->colors["white"].str_repeat("H", 25)).$this->colors["default"]; |
|
| 394 | 392 | } else { |
| 395 | 393 | $part2 = $this->colors["red"].str_repeat(".", 25).$this->colors["default"]; |
| 396 | 394 | } |
@@ -107,8 +107,7 @@ discard block |
||
| 107 | 107 | if (!is_null($this->config["dbf_list"])) { |
| 108 | 108 | if (is_array($this->config["dbf_list"])) { |
| 109 | 109 | $this->config["dbf_list"] = array_map("strtolower", $this->config["dbf_list"]); |
| 110 | - } |
|
| 111 | - else { |
|
| 110 | + } else { |
|
| 112 | 111 | $this->writeLog("<red>Error in config:<default> dbf list should be array or null"); |
| 113 | 112 | exit; |
| 114 | 113 | } |
@@ -137,8 +136,7 @@ discard block |
||
| 137 | 136 | try { |
| 138 | 137 | $this->db = new PDO("mysql:host=".$this->config["db_host"].";port=".$this->config["db_port"].";dbname=" . $this->config["db_name"], |
| 139 | 138 | $this->config["db_username"], $this->config["db_password"], $db_options); |
| 140 | - } |
|
| 141 | - catch (PDOException $e) { |
|
| 139 | + } catch (PDOException $e) { |
|
| 142 | 140 | $this->writeLog("<red>Error in MySQL connection:<default> ".$e->getMessage()); |
| 143 | 141 | exit; |
| 144 | 142 | } |
@@ -188,8 +186,7 @@ discard block |
||
| 188 | 186 | case "0": |
| 189 | 187 | if ($column["decimal"]) { |
| 190 | 188 | $line[] = $name." decimal(".($column["length"] + $column["decimal"]).", ".$column["decimal"].") NULL DEFAULT 0"; |
| 191 | - } |
|
| 192 | - else { |
|
| 189 | + } else { |
|
| 193 | 190 | $line[] = $name." bigint(".$column["length"].") NULL DEFAULT 0"; |
| 194 | 191 | } |
| 195 | 192 | break; |
@@ -225,8 +222,7 @@ discard block |
||
| 225 | 222 | COMMENT='Converted DBF file: ".$this->dbfHeaders["table"].".dbf'"); |
| 226 | 223 | if ($result !== false) { |
| 227 | 224 | $this->writeLog("Table <yellow>".$this->dbfHeaders["table"]."<default> successfully created"); |
| 228 | - } |
|
| 229 | - else { |
|
| 225 | + } else { |
|
| 230 | 226 | $this->writeLog("<red>Error in MySQL:<default> ".print_r($this->db->errorInfo(), true)); |
| 231 | 227 | } |
| 232 | 228 | } |
@@ -264,13 +260,11 @@ discard block |
||
| 264 | 260 | $deleted = false; |
| 265 | 261 | if ($this->config["deleted_records"]) { |
| 266 | 262 | $result->execute($record); |
| 267 | - } |
|
| 268 | - else { |
|
| 263 | + } else { |
|
| 269 | 264 | if (!$record["deleted"]) { |
| 270 | 265 | unset($record["deleted"]); |
| 271 | 266 | $result->execute($record); |
| 272 | - } |
|
| 273 | - else { |
|
| 267 | + } else { |
|
| 274 | 268 | $deleted = true; |
| 275 | 269 | } |
| 276 | 270 | } |
@@ -330,8 +324,7 @@ discard block |
||
| 330 | 324 | $type = "tinyint"; |
| 331 | 325 | } |
| 332 | 326 | } |
| 333 | - } |
|
| 334 | - else { |
|
| 327 | + } else { |
|
| 335 | 328 | if (!$column["decimal"]) { |
| 336 | 329 | $type = "bigint"; |
| 337 | 330 | if ($result["min"] >= -128 && $result["max"] <= 127) { |
@@ -348,8 +341,7 @@ discard block |
||
| 348 | 341 | if ($column["decimal"] && $unsigned) { |
| 349 | 342 | $lines[] = "CHANGE `".$column["name"]."` `".$column["name"]."` decimal(".($column["length"] + $column["decimal"]).", ".$column["decimal"].") UNSIGNED |
| 350 | 343 | NULL DEFAULT '0'"; |
| 351 | - } |
|
| 352 | - else { |
|
| 344 | + } else { |
|
| 353 | 345 | $lines[] = "CHANGE `".$column["name"]."` `".$column["name"]."` ".$type."(".$column["length"].")".($unsigned ? " UNSIGNED" : "")." |
| 354 | 346 | NULL DEFAULT '0'"; |
| 355 | 347 | } |