I have the following INSERT in a db_query, but feel like I should convert it to a db_insert, but can't figure out the syntax:
INSERT INTO {mytable} VALUES (23, 'foo', 'bar', 42)
This example is fairly short, but I do work with some legacy tables that have MANY fields.
$insert = db_insert('variables')->values(array(23, 'foo', 'bar', 42));
$insert->execute();
The above gives me "NoFieldsException: There are no fields available to insert with. in InsertQuery->preExecute()".
How can you perform an insert with db_insert without needing to specify each field name? I can make it work in D7 with db_query([INSERT...]); but drupal_write_record does not work.