Skip to content

Commit cdd185b

Browse files
committed
Merge pull request #264 from avbdr/master
fixes
2 parents b072103 + dd69e99 commit cdd185b

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

MysqliDb.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,6 @@ public function rawQuery ($query, $bindParams = null, $sanitize = true)
285285
{
286286
$params = array(''); // Create the empty 0 index
287287
$this->_query = $query;
288-
if ($sanitize)
289-
$this->_query = filter_var ($query, FILTER_SANITIZE_STRING,
290-
FILTER_FLAG_NO_ENCODE_QUOTES);
291288
$stmt = $this->_prepareQuery();
292289

293290
if (is_array($bindParams) === true) {
@@ -921,21 +918,18 @@ protected function _buildTableData ($tableData) {
921918
if (!is_array ($tableData))
922919
return;
923920

924-
$isInsert = strpos ($this->_query, 'INSERT');
925-
$isUpdate = strpos ($this->_query, 'UPDATE');
926-
927-
if ($isInsert !== false) {
928-
$this->_query .= ' (`' . implode(array_keys($tableData), '`, `') . '`)';
929-
$this->_query .= ' VALUES (';
930-
} else
921+
$isInsert = preg_match ('/^[INSERT|REPLACE]/', $this->_query);
922+
if ($isInsert)
923+
$this->_query .= ' (`' . implode(array_keys($tableData), '`, `') . '`) VALUES (';
924+
else
931925
$this->_query .= " SET ";
932926

933927
foreach ($tableData as $column => $value) {
934-
if ($isUpdate !== false)
928+
if (!$isInsert)
935929
$this->_query .= "`" . $column . "` = ";
936930

937931
// Subquery value
938-
if (is_object ($value)) {
932+
if ($value instanceof MysqliDb) {
939933
$this->_query .= $this->_buildPair ("", $value) . ", ";
940934
continue;
941935
}
@@ -969,8 +963,8 @@ protected function _buildTableData ($tableData) {
969963
die ("Wrong operation");
970964
}
971965
}
972-
$this->_query = rtrim($this->_query, ', ');
973-
if ($isInsert !== false)
966+
$this->_query = rtrim ($this->_query, ', ');
967+
if ($isInsert)
974968
$this->_query .= ')';
975969
}
976970

0 commit comments

Comments
 (0)