Permalink
Browse files

Adding early return when connection to MySQL or MySQLi fails.

Fixes #1732
  • Loading branch information...
1 parent 41d2852 commit 3189872ea97cbe96c11aa943e89e57fcda43d94d @markstory markstory committed Jun 25, 2011
Showing with 6 additions and 0 deletions.
  1. +4 −0 cake/libs/model/datasources/dbo/dbo_mysql.php
  2. +2 −0 cake/libs/model/datasources/dbo/dbo_mysqli.php
@@ -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;
}
@@ -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", ">=");

0 comments on commit 3189872

Please sign in to comment.