/**
  * Loads the schema into memory according to the config (e.g. only includes
  * databases and tables the config allows).
  * 
  * This function is mostly the first pass in schema generator. A good second
  * pass would be to attempt to link any relationships not possible through
  * FK detection. See {@link linkRelationships()}.
  *
  * @return void
  **/
 public function loadSchema()
 {
     $dsn = $this->config->getDsn();
     // Load the driver-specific classes
     $driver = ucfirst(strtolower($dsn['driver']));
     $this->loadDrivers(dirname(__FILE__) . '/drivers/mysql/', $driver);
     // Construct the server/schema class and start loading databases according to the configuration options.
     $serverClass = $driver . 'Server';
     $server = new $serverClass($dsn);
     $dbNames = $server->getAvailableDatabaseNames();
     foreach ($dbNames as $dbName) {
         if ($this->config->shouldProcessDatabase($dbName)) {
             if ($this->verbose) {
                 echo 'Scanning database `' . $dbName . "`\n";
             }
             $database = $server->loadDatabase($dbName);
             foreach ($database->getAvailableTableNames() as $tableName) {
                 if ($this->config->shouldProcessTable($dbName, $tableName)) {
                     if ($this->verbose) {
                         echo "\tScanning table `" . $tableName . "`\n";
                     }
                     $table = $database->loadTable($tableName);
                     $pkOverride = $this->config->getPrimaryKeyOverride($dbName, $tableName);
                     if (!empty($pkOverride)) {
                         // Config could be an array or single string, so convert it as needed:
                         if (!is_array($pkOverride)) {
                             $pkOverride = array($pkOverride);
                         }
                         // Remove any existing PK
                         foreach ($table->getPrimaryKey() as $column) {
                             $column->setIsPrimaryKey(false);
                         }
                         // Now set the PK override
                         foreach ($pkOverride as $columnName) {
                             $column = $table->getColumn($columnName);
                             $column->setIsPrimaryKey(true);
                         }
                     }
                 } else {
                     if ($this->verbose) {
                         echo "\tSkipping table `" . $tableName . "`\n";
                     }
                 }
             }
         } else {
             if ($this->verbose) {
                 echo 'Skipping database `' . $dbName . "`\n";
             }
         }
     }
     $this->setSchema($server);
 }