Commit dd69e990 authored by Alexander Butenko's avatar Alexander Butenko

Fix for a replace()

parent 22017a4b
...@@ -918,21 +918,18 @@ class MysqliDb ...@@ -918,21 +918,18 @@ class MysqliDb
if (!is_array ($tableData)) if (!is_array ($tableData))
return; return;
$isInsert = strpos ($this->_query, 'INSERT'); $isInsert = preg_match ('/^[INSERT|REPLACE]/', $this->_query);
$isUpdate = strpos ($this->_query, 'UPDATE'); if ($isInsert)
$this->_query .= ' (`' . implode(array_keys($tableData), '`, `') . '`) VALUES (';
if ($isInsert !== false) { else
$this->_query .= ' (`' . implode(array_keys($tableData), '`, `') . '`)';
$this->_query .= ' VALUES (';
} else
$this->_query .= " SET "; $this->_query .= " SET ";
foreach ($tableData as $column => $value) { foreach ($tableData as $column => $value) {
if ($isUpdate !== false) if (!$isInsert)
$this->_query .= "`" . $column . "` = "; $this->_query .= "`" . $column . "` = ";
// Subquery value // Subquery value
if (is_object ($value)) { if ($value instanceof MysqliDb) {
$this->_query .= $this->_buildPair ("", $value) . ", "; $this->_query .= $this->_buildPair ("", $value) . ", ";
continue; continue;
} }
...@@ -966,8 +963,8 @@ class MysqliDb ...@@ -966,8 +963,8 @@ class MysqliDb
die ("Wrong operation"); die ("Wrong operation");
} }
} }
$this->_query = rtrim($this->_query, ', '); $this->_query = rtrim ($this->_query, ', ');
if ($isInsert !== false) if ($isInsert)
$this->_query .= ')'; $this->_query .= ')';
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment