case 'reject': $content->rejected[] = (object) ['errorCode' => 201, 'message' => 'Table reached max rows.', 'record' => $entry]; $rejected = true; break; # Truncating the table (delete and recreate for speed) # Truncating the table (delete and recreate for speed) case 'truncate': $G_TO_TABLE_DETAILS = recreate_table($G_CONTROLLER_DBLINK, $G_TO_TABLE_DETAILS); break; } } # If its not rejected, time to add this row if (!$rejected) { # Inserting into our partition $to_query->set_table($to_partition->data['table_name'], false, false, $to_partition->database); $query = $to_query->get_insert_query(isset($_CGET['ignore']), false); mysqli_sub_query($to_partition->dblink, $query); # Insterted - mysqli_affected_rows = 1 if (mysqli_affected_rows($to_partition->dblink) == 1) { $content->inserted_ids[] = $entry->id; $inserted_count++; $partitions_affected->{$to_partition->data['id']}->inserted_rows++; $G_TO_TABLE_DETAILS['rows'] = (int) $G_TO_TABLE_DETAILS['rows'] + 1; } else { $content->update_ids[] = mysqli_insert_id($to_partition->dblink); } $write_rows++; } } # If we need to remove from the from table if (isset($_CGET['delete']) && boolval($_CGET['delete'])) {
$content->rejected[] = (object) ['errorCode' => 201, 'message' => 'Table reached max rows.', 'record' => $entry]; $rejected = true; break; # Truncating the table (delete and recreate for speed) # Truncating the table (delete and recreate for speed) case 'truncate': $G_TABLE_DETAILS = recreate_table($G_CONTROLLER_DBLINK, $G_TABLE_DETAILS); break; } } } } # If its not rejected, time to add this row if (!BULK_INSERT && !$rejected) { # Inserting into our partition $insert_query = $query->get_insert_query(isset($_CGET['ignore'])); $result = mysqli_sub_query($partition->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 inserting the record.', 'record' => $entry]; } elseif (mysqli_affected_rows($partition->dblink) == 1) { $content->insert_ids[] = $entry->id; $partitions_affected->{$partition->data['id']}->last_insert_id = max($partitions_affected->{$partition->data['id']}->last_insert_id, $entry->id); $inserted_count++; $partitions_affected->{$partition->data['id']}->inserted_rows++; $G_TABLE_DETAILS['rows'] = (int) $G_TABLE_DETAILS['rows'] + 1; } else { $content->update_ids[] = mysqli_insert_id($partition->dblink); }