title: How to prevent Yii from opening the database automatically
body: <p>I am using Yii 1.1.17 for my portal. I use the same application to connect into different databases depending on domain name.
  I write the fake params in <strong><code>main.php</code></strong> </p>
  
  <pre><code>'db'=&gt;array(
     'connectionString' =&gt; 'mysql:host=localhost;dbname=db',           
     'emulatePrepare' =&gt; TRUE,
     'active' =&gt; FALSE,
     'username' =&gt; 'dbUser',
     'password' =&gt; 'dbP@ssW0rd',
     'charset' =&gt; 'utf8'
  ),
  </code></pre>
  
  <p>Then change them in <strong><code>Controller.php</code></strong> like this:</p>
  
  <pre><code>// get database params from url
          $url = Yii::app()-&gt;request-&gt;serverName;
          $db_param = explode(".",$url);
          $db = Yii::app()-&gt;params['db'][$db_param[0]];
          Yii::app()-&gt;db-&gt;setActive(false);
          Yii::app()-&gt;db-&gt;connectionString = mysql:host=127.0.0.1;dbname=$db";
          Yii::app()-&gt;db-&gt;username = $db;
          Yii::app()-&gt;db-&gt;setActive(true);
  </code></pre>
  
  <p><code>username</code> is the same as <code>dbname</code>, and <code>password</code> is the same for all databases.
  When I open the portal it gives me</p>
  
  <pre><code> CDbException
   CDbConnection failed to open the DB connection.
  </code></pre>
  
  <p>But when I write the real values of live database in <code>connectionString</code> and <code>username</code> inside <strong><code>main.php</code></strong> it opens then changes this values and connects into correct database.</p>
  
  <p>My question is:
  How to prevent Yii to connect automatically before running code in <strong><code>Controller.php</code></strong>. I set <code>'active' =&gt; FALSE</code>, but it does not help.</p>