Query D6 db from D7 module I want to import a content type data from D6 db to D7. 
I have db in settings file like....

    /**
     * Database
     */
    $databases['default']['default'] = array(
      'driver' =&gt; 'mysql',
      'database' =&gt; 'd7',
      'username' =&gt; 'root',
      'password' =&gt; 'root',
      'host' =&gt; 'localhost',
    );
    $databases['d6']['default'] = array(
      'driver' =&gt; 'mysql',
      'database' =&gt; 'd6',
      'username' =&gt; 'root',
      'password' =&gt; 'root',
      'host' =&gt; 'localhost',
    );


I am trying to query nid's from D6 db from D7 module using db_query, but cant use node_load for D6 db then. 

    function import_schools() {
      db_set_active($key = 'd6');

      $result = db_query("SELECT nid FROM {node} WHERE type = :type AND nid         = :nid", array(
        ':type' =&gt; 'classified',
        ':nid' =&gt; '77307',
      ));

      while ($record = $result-&gt;fetchAssoc()) {
        print_r($record);
        print_r(node_load($record['nid']));
      }

    }


How can I chang API from d7 to d6 on fly while switching db using db_set_active.
If you are looking to Migrate D6 Content (Nodes) to D7 system then you can use Drupal-to-Drupal data migration module.

Project page says


  migrate_d2d provides a framework based on the Migrate API for
  migrating content from Drupal 5, Drupal 6, or Drupal 7 sites into the
  Drupal 7 site where it is installed.