Removing silent errors in PDO dbo's when a connection exception is created.

Adding the host param for mysql.
Adding a test for mysql missing the host param.
Fixes #1427
This commit is contained in:
mark_story 2011-01-03 23:34:22 -05:00
parent d3d009588d
commit de6eda964e
4 changed files with 19 additions and 6 deletions

View file

@ -148,14 +148,14 @@ class DboMysql extends DboSource {
$flags[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . $config['encoding'];
}
$this->_connection = new PDO(
"mysql:{$config['host']};port={$config['port']};dbname={$config['database']}",
"mysql:host={$config['host']};port={$config['port']};dbname={$config['database']}",
$config['login'],
$config['password'],
$flags
);
$this->connected = true;
} catch (PDOException $e) {
$this->errors[] = $e->getMessage();
throw new MissingConnectionException(array('class' => $e->getMessage()));
}
$this->_useAlias = (bool)version_compare($this->getVersion(), "4.1", ">=");

View file

@ -130,7 +130,7 @@ class DboPostgres extends DboSource {
$this->_execute('SET search_path TO ' . $config['schema']);
}
} catch (PDOException $e) {
$this->errors[] = $e->getMessage();
throw new MissingConnectionException(array('class' => $e->getMessage()));
}
return $this->connected;

View file

@ -114,9 +114,8 @@ class DboSqlite extends DboSource {
$this->_connection = new PDO('sqlite:' . $config['database'], null, null, $flags);
$this->_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->connected = true;
}
catch(PDOException $e) {
$this->errors[] = $e->getMessage();
} catch(PDOException $e) {
throw new MissingConnectionException(array('class' => $e->getMessage()));
}
return $this->connected;
}