@@ -918,21 +918,18 @@ protected function _buildTableData ($tableData) {
918918 if (!is_array ($ tableData ))
919919 return ;
920920
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
928925 $ this ->_query .= " SET " ;
929926
930927 foreach ($ tableData as $ column => $ value ) {
931- if ($ isUpdate !== false )
928+ if (! $ isInsert )
932929 $ this ->_query .= "` " . $ column . "` = " ;
933930
934931 // Subquery value
935- if (is_object ( $ value) ) {
932+ if ($ value instanceof MysqliDb ) {
936933 $ this ->_query .= $ this ->_buildPair ("" , $ value ) . ", " ;
937934 continue ;
938935 }
@@ -966,8 +963,8 @@ protected function _buildTableData ($tableData) {
966963 die ("Wrong operation " );
967964 }
968965 }
969- $ this ->_query = rtrim ($ this ->_query , ', ' );
970- if ($ isInsert !== false )
966+ $ this ->_query = rtrim ($ this ->_query , ', ' );
967+ if ($ isInsert )
971968 $ this ->_query .= ') ' ;
972969 }
973970
0 commit comments