Migration from a remote database PDOException I'm setting up a database migration. For now, I'm using the ssh tunnel to access the remote databse.

Here is the configuration in the Migration class:

&lt;?php
...
Database::addConnectionInfo('for_migration', 'default', array(
  'driver' =&gt; 'mysql',
  'database' =&gt; 'database',
  'username' =&gt; 'user',
  'password' =&gt; '****',
  'host' =&gt; '127.0.0.1',
  'port' =&gt; '1000',
  'prefix' =&gt; '',
));

// Conect to the remote $databases
$query = Database::getConnection('default', 'for_migration')
    -&gt;select('Content', 'ct');

// Better descriptions for wineid and name; best_vintages is added in prepareRow()
$source_fields = array(
  'id' =&gt; t('article ID'),
  'contenido' =&gt; t('Contenido'),
);

// Create a MigrateSource object, which manages retrieving the input data.
// Tell the source class not to try to join the map table.
$this-&gt;source = new MigrateSourceSQL($query,
    $source_fields,
    NULL,
    array('map_joinable' =&gt; FALSE)
    );

$this-&gt;destination = new MigrateDestinationNode('article');

$this-&gt;map = new MigrateSQLMap($this-&gt;machineName,
    array(
        'id' =&gt; array('type' =&gt; 'int',
                           'not null' =&gt; TRUE,
                           'description' =&gt; 'Article ID',
                           'alias' =&gt; 'id',
                          ),
        ),
        MigrateDestinationNode::getKeySchema(),
        'for_migration'
    );

// @todo Mapped fields
$this-&gt;addFieldMapping('body', 'content');
?&gt;


When I try to access the migration UI page the count of items is correct, but I get and error when I try to load the task page to visualize the mappings and elements.

DOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM Content ct LIMIT 1 OFFSET 0' at line 1: SELECT FROM {Content} ct LIMIT 1 OFFSET 0; Array ( ) in MigrateSourceSQL-&gt;fields() (line 211 of /Users/brightsitesSM/Sites/devdesktop/independentpoc-dev/docroot/sites/all/modules/migrate/plugins/sources/sql.inc).


Probably there is something missing in the code as the SELECT in the SQL query is empty.

Here are the screenshots of the migration page:


... and the task page error:
The problem with the code is the connection to the database. There aren't fields in the select.

SELECT FROM {Content} ct


To solve that one of the solutions is adding ->fields('ct'); to the database connection. This will select all the fields from the table ct:

SELECT ct.* FROM {Content} ct