@@ -918,21 +918,18 @@ protected function _buildTableData ($tableData) {
918
918
if (!is_array ($ tableData ))
919
919
return ;
920
920
921
- $ isInsert = strpos ($ this ->_query , 'INSERT ' );
922
- $ isUpdate = strpos ($ this ->_query , 'UPDATE ' );
923
-
924
- if ($ isInsert !== false ) {
925
- $ this ->_query .= ' (` ' . implode (array_keys ($ tableData ), '`, ` ' ) . '`) ' ;
926
- $ this ->_query .= ' VALUES ( ' ;
927
- } else
921
+ $ isInsert = preg_match ('/^[INSERT|REPLACE]/ ' , $ this ->_query );
922
+ if ($ isInsert )
923
+ $ this ->_query .= ' (` ' . implode (array_keys ($ tableData ), '`, ` ' ) . '`) VALUES ( ' ;
924
+ else
928
925
$ this ->_query .= " SET " ;
929
926
930
927
foreach ($ tableData as $ column => $ value ) {
931
- if ($ isUpdate !== false )
928
+ if (! $ isInsert )
932
929
$ this ->_query .= "` " . $ column . "` = " ;
933
930
934
931
// Subquery value
935
- if (is_object ( $ value) ) {
932
+ if ($ value instanceof MysqliDb ) {
936
933
$ this ->_query .= $ this ->_buildPair ("" , $ value ) . ", " ;
937
934
continue ;
938
935
}
@@ -966,8 +963,8 @@ protected function _buildTableData ($tableData) {
966
963
die ("Wrong operation " );
967
964
}
968
965
}
969
- $ this ->_query = rtrim ($ this ->_query , ', ' );
970
- if ($ isInsert !== false )
966
+ $ this ->_query = rtrim ($ this ->_query , ', ' );
967
+ if ($ isInsert )
971
968
$ this ->_query .= ') ' ;
972
969
}
973
970
0 commit comments