How to run, execute insert query in Drupal 8

How to run, execute insert query in Drupal 8

“There may be several other possible ways, but I know one simple one and sticked to it.

$db = \Drupal::database();

$db->insert($table_name)->fields($fields_array_key_value_pair)->execute(); 

Thats it.

 

 “

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *