Insert/add record using insert query via resourceConnection in Magento 2.

You can create custom insert query using Magento 2 to add/create a new record in database table via ResourceConnection class.

Using the Insert query, You can add a new record to the table using direct SQL query insert() without going to model operation.

Let’s we are adding a new record in sales_order_status table, that contains two columns only status and label

The First argument is the table name.

The Second argument is an array of columns of table.

The output is the new row added to sales_order_status table. You can add any no. of record in any table using insert() query.
Check for other Direct Sql Query in Magento 2
.