Get id of row inserted into database I insert data into database table using query builder:

$command = Craft::$app-&gt;db-&gt;createCommand()-&gt;insert('test2', array());
$command-&gt;execute();


How can i retrieve id of newly inserted db row?
I believe you can use getLastInsertID to fetch the ID:

Craft::$app-&gt;db-&gt;getLastInsertID();