Skip to content

Commit

Permalink
Adding early return when connection to MySQL or MySQLi fails.
Browse files Browse the repository at this point in the history
Fixes #1732
  • Loading branch information
markstory committed Jun 25, 2011
1 parent 41d2852 commit 3189872
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cake/libs/model/datasources/dbo/dbo_mysql.php
Expand Up @@ -564,6 +564,10 @@ function connect() {
$this->connection = mysql_pconnect($config['host'] . ':' . $config['port'], $config['login'], $config['password']);
}

if (!$this->connection) {
return false;
}

if (mysql_select_db($config['database'], $this->connection)) {
$this->connected = true;
}
Expand Down
2 changes: 2 additions & 0 deletions cake/libs/model/datasources/dbo/dbo_mysqli.php
Expand Up @@ -64,6 +64,8 @@ function connect() {

if ($this->connection !== false) {
$this->connected = true;
} else {
return false;
}

$this->_useAlias = (bool)version_compare(mysqli_get_server_info($this->connection), "4.1", ">=");
Expand Down

0 comments on commit 3189872

Please sign in to comment.