ensure to use the correct db in all cases

`$this->db` is always a db connection after beforeAction() has been
called. `Yii::$app->db` is the default but that can be changed with the
`--db` argument of the command.