[support] Can't change database connection
Tim Johnson
tim at akwebsoft.com
Wed Jan 2 19:06:42 UTC 2013
* Earnie Boyd <earnie at users.sourceforge.net> [130101 18:38]:
> The schema doesn't come from the database but from the modules that
> implement a schema. The schema will exist regardless of which
> connection you're connected to.
> http://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_get_schema/7
Understood. Thank you for the reply. I intended the schema call as
sort of a diagnostic. The real goal is to insert data into the
'external' database. So here is the code I have now:
// code begins
$dba = array (
'driver' => 'mysql',
'database' => 'dolphy_books',
'host' => 'localhost',
'username' => 'tim',
'password' => '******',
'port' => '3306',
);
Database::addConnectionInfo('db1','default',$dba);
db_set_active('db1');
$result = Database::getConnectionInfo('db1');
drupal_set_message("<b>Now : Connection Info</b>: <pre>" . print_r($result,1) . '</pre>');
$inserter = db_insert('providers');
// code ends
When this code is executed, I get an error: as follows
"""
Additional uncaught exception thrown while handling exception.
Original
PDOException: SQLSTATE[HY000] [2002] No such file or directory in db_insert()
(line 2398 of /Users/http/sites/daily/includes/database/database.inc).
Additional
PDOException: SQLSTATE[HY000] [2002] No such file or directory in db_select()
(line 2491 of /Users/http/sites/daily/includes/database/database.inc).
Uncaught exception thrown in session handler.
PDOException: SQLSTATE[HY000] [2002] No such file or directory in db_merge()
(line 2416 of /Users/http/sites/daily/includes/database/database.inc).
"""
So what am I doing wrong?
Thanks again for the help.
--
Tim
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com
More information about the support
mailing list