Throw a DbException if lastInsertId() has no reference

For example, db()->lastInsertId() on a ReplicatedConnection
if there has not actually been any prepare() previously