Fixed bug wherein we expected parent_id to be valid when getting last insert row ID, but that's only valid if an insert actually took place. Instead, perform a separate query to grab it.