How do I save data into a custom table on form submit? Number of columns in my custom table is huge. How do i insert data in custom table on form submit in Drupal 8?
I want to use something similar to drupal_write_record('table_name', $form_state['values']); in Drupal8.
As per the change record, drupal_write_record has been removed, with the new advice being:


  Developers should use \Drupal::database()-&gt;merge(), the Entity API or one of the provided services, like key value.


As you're using a custom table, you'll need the first method. An example from that change record:

\Drupal::database()-&gt;merge('example_deleted_entity_statistics')
  -&gt;key(array('type' =&gt; $type, 'id' =&gt; $id))
  -&gt;fields(array('count' =&gt; $count))
  -&gt;execute();


As always, inject the database service if possible, rather than requesting it from \Drupal.