I use Drupal 7.x-dev(2010.11.30)
1.In files "settings.php":
$databases['default']['default'] = array(
'driver' => 'pgsql',
'database' => 'drupal7',
'username' => 'postgres',
'password' => '',
'host' => 'localhost',
'port' => '',
'prefix' => '',
);
$databases['default']['climdb'][] = array(
'driver' => 'pgsql',
'database' => 'climdb',
'username' => 'postgres',
'password' => '',
'host' => 'localhost',
);
climdb and drupal7 is a database in one postgresql server.
2.In file "modules":
function dbtng_humanmis_entry_load($entry = array()) {
// Read all fields from the A01 table.
$newdb=db_set_active('climdb');
echo $newdb;
$select = db_select('A01', 'e');//A01 is a table in database "climdb".
$select->fields('e');
// Add each field and value as a condition to this query.
foreach ($entry as $field => $value) {
$select->condition($field, $value);
}
// Return the result in object format.
db_set_active();
return $select->execute()->fetchAll();
}
3. direct use database "drupal7" is ok;
but when I want use "climdb":
the drupal7 comes the error message: