title: Dynamically Change Database with Laravel
body: <p>I am new to Laravel and have done quite a bit of searching on this to on avail.</p>
  
  <p>I am creating a system that will ideally create a new database and tables upon user creation.</p>
  
  <p>I am having trouble switching databases dynamically and then create a table. </p>
  
  <pre><code>        DB::statement("CREATE DATABASE " . $new_db_name);
          DB::connection('mysql')-&gt;setDatabaseName($new_db_name);
  </code></pre>
  
  <p>Creates the new table and I believe will changes database to, I confirm this by running</p>
  
  <pre><code>        echo DB::connection('mysql')-&gt;getDatabaseName();
  </code></pre>
  
  <p>But when I run the create table command the table is created in the old database.  Any ideas?</p>
  
  <p>Thanks in advanced.</p>