@@ -285,9 +285,6 @@ public function rawQuery ($query, $bindParams = null, $sanitize = true)
285
285
{
286
286
$ params = array ('' ); // Create the empty 0 index
287
287
$ this ->_query = $ query ;
288
- if ($ sanitize )
289
- $ this ->_query = filter_var ($ query , FILTER_SANITIZE_STRING ,
290
- FILTER_FLAG_NO_ENCODE_QUOTES );
291
288
$ stmt = $ this ->_prepareQuery ();
292
289
293
290
if (is_array ($ bindParams ) === true ) {
@@ -921,21 +918,18 @@ protected function _buildTableData ($tableData) {
921
918
if (!is_array ($ tableData ))
922
919
return ;
923
920
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
931
925
$ this ->_query .= " SET " ;
932
926
933
927
foreach ($ tableData as $ column => $ value ) {
934
- if ($ isUpdate !== false )
928
+ if (! $ isInsert )
935
929
$ this ->_query .= "` " . $ column . "` = " ;
936
930
937
931
// Subquery value
938
- if (is_object ( $ value) ) {
932
+ if ($ value instanceof MysqliDb ) {
939
933
$ this ->_query .= $ this ->_buildPair ("" , $ value ) . ", " ;
940
934
continue ;
941
935
}
@@ -969,8 +963,8 @@ protected function _buildTableData ($tableData) {
969
963
die ("Wrong operation " );
970
964
}
971
965
}
972
- $ this ->_query = rtrim ($ this ->_query , ', ' );
973
- if ($ isInsert !== false )
966
+ $ this ->_query = rtrim ($ this ->_query , ', ' );
967
+ if ($ isInsert )
974
968
$ this ->_query .= ') ' ;
975
969
}
976
970
0 commit comments