Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

XML import fix for SQLite duplicate rows

givanz3b0bd4ac385c
diff --git a/system/db/sqlite.php b/system/db/sqlite.php
index 78b67af..15d9c68 100755
--- a/system/db/sqlite.php
+++ b/system/db/sqlite.php
@@ -240,7 +240,7 @@ class Sqlite extends DBDriver {
throw new \Exception($message, $e->getCode());
}
- if ($stmt && ! empty($paramTypes)) {
+ if ($stmt/* && ! empty($paramTypes)*/) {
foreach ($parameters as $key => $value) {
$type = $types[$key] ?? 's';
$type = ($type == 'i') ? SQLITE3_INTEGER : SQLITE3_TEXT;
diff --git a/system/import/xml.php b/system/import/xml.php
index 8f5bec6..729e12d 100755
--- a/system/import/xml.php
+++ b/system/import/xml.php
@@ -283,11 +283,17 @@ class Xml {
}
}
- $cols = implode("$q,$q",array_keys($data));
- $values = implode(',:',array_keys($data));
+ $cols = implode("$q, $q",array_keys($data));
+ $values = implode(', :',array_keys($data));
- $sql = "INSERT INTO $q$tableName$q ($q$cols$q) VALUES (:$values)" .
- "ON DUPLICATE KEY UPDATE $update\n\n";
+ $duplicate = "ON DUPLICATE KEY UPDATE $update\n\n";
+
+ if (DB_ENGINE == 'sqlite' || DB_ENGINE == 'pgsql') {
+ //$duplicate = "ON CONFLICT($q$cols$q) DO UPDATE SET $update\n\n";
+ $duplicate = '';
+ }
+
+ $sql = "INSERT INTO $q$tableName$q ($q$cols$q) VALUES (:$values)" . $duplicate;
$stmt = $this->db->execute($sql, $data);
$lastId = $this->db->insert_id;