title: Yii 2.0 : 2 database connection
body: <p>I read this question <a href="https://stackoverflow.com/questions/27254540/yii-2-0-multiple-database-connection?answertab=active#tab-top">yii 2.0 multiple database connection</a>, and use the answer of @Ali MasudianPour.</p>
  
  <p>I follow the first step: </p>
  
  <blockquote>
    <p>First you need to configure your databases like below:</p>
  </blockquote>
  
  <pre><code>return [
      'components' =&gt; [
          'db1' =&gt; [
              'class' =&gt; 'yii\db\Connection',
              'dsn' =&gt; 'mysql:host=localhost;dbname=database1',
              'username' =&gt; 'root',
              'password' =&gt; '',
              'charset' =&gt; 'utf8',
          ],
          'db2' =&gt; [
              'class' =&gt; 'yii\db\Connection',
              'dsn' =&gt; 'mysql:host=localhost;dbname=database2',
              'username' =&gt; 'root',
              'password' =&gt; '',
              'charset' =&gt; 'utf8',
          ],
      ],
  ]; ?&gt;
  </code></pre>
  
  <p>But in my configuration in my <code>db</code> it gives me this error:</p>
  
  <blockquote>
    <p>The configuration for the "db" component must contain a "class"
    element.</p>
  </blockquote>