Commit dd69e990 authored by Alexander Butenko's avatar Alexander Butenko

Fix for a replace()

parent 22017a4b
......@@ -918,21 +918,18 @@ class MysqliDb
if (!is_array ($tableData))
return;
$isInsert = strpos ($this->_query, 'INSERT');
$isUpdate = strpos ($this->_query, 'UPDATE');
if ($isInsert !== false) {
$this->_query .= ' (`' . implode(array_keys($tableData), '`, `') . '`)';
$this->_query .= ' VALUES (';
} else
$isInsert = preg_match ('/^[INSERT|REPLACE]/', $this->_query);
if ($isInsert)
$this->_query .= ' (`' . implode(array_keys($tableData), '`, `') . '`) VALUES (';
else
$this->_query .= " SET ";
foreach ($tableData as $column => $value) {
if ($isUpdate !== false)
if (!$isInsert)
$this->_query .= "`" . $column . "` = ";
// Subquery value
if (is_object ($value)) {
if ($value instanceof MysqliDb) {
$this->_query .= $this->_buildPair ("", $value) . ", ";
continue;
}
......@@ -966,8 +963,8 @@ class MysqliDb
die ("Wrong operation");
}
}
$this->_query = rtrim($this->_query, ', ');
if ($isInsert !== false)
$this->_query = rtrim ($this->_query, ', ');
if ($isInsert)
$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