code: public function init()
      {
          parent::init();
          $this->db = Instance::ensure($this->db, Connection::className());
          if ($this->sql === null) {
              throw new InvalidConfigException('The "sql" property must be set.');
          }
      }
docs: Initializes the DB connection component.
  This method will initialize the [[db]] property to make sure it refers to a valid DB connection.
  @throws InvalidConfigException if [[db]] is invalid.