title: Fetching column types in Laravel
body: <p>I'm creating a Laravel project for which I need to dynamically retrieve column names and their types for some tables in the (MySQL) database. Currently, this is my solution:</p>
  
  <pre><code>$columnTypes = array();
  $columns = Schema::getColumnListing($tableName);
  foreach($columns as $columnName) {
      $columnTypes[$columnName] = DB::connection()-&gt;getDoctrineColumn($tableName, $columnName)-&gt;getType()-&gt;getName();
  }
  </code></pre>
  
  <p>Unfortunately, this requires a lot of queries, and thus a lot of time (up to ~100ms per table).</p>
  
  <p>Is there a faster way to retrieve the types of the columns?</p>