$write_rows++; } } # Freeing memory unset($partition_entries->{$partition->data['id']}); } # Handling bulk inserts if (BULK_INSERT) { # Looping through each partitions queries foreach ($partition_queries as $id => $query) { # Speeding things up $env_query = "\tSET unique_checks=0;\n\t\t\t\t\tSET foreign_key_checks=0;\n\t\t\t\t\tSET autocommit=0;"; mysqli_multi_sub_query($partitions_affected->{$id}->dblink, $env_query); # Processing each insert batch $inserted_rows = 0; while ($insert_query = $query->get_bulk_insert_query()) { # Inserting $result = mysqli_sub_query($partitions_affected->{$id}->dblink, $insert_query); # If we had a bad insert if (!$result) { $content->success = false; $content->message = 'Not all records were inserted.'; $content->rejected[] = (object) ['errorCode' => 202, 'message' => 'There was an error bulk inserting the records.']; } else { $inserted_rows += mysqli_affected_rows($partitions_affected->{$id}->dblink); } } # We added something alright if ($inserted_rows != 0) { $inserted_count += $inserted_rows; $content->insert_ids = array_merge($content->insert_ids, $partition_queries_ids->{$id});