Skip to content

Commit

Permalink
Return false when no connection can be made
Browse files Browse the repository at this point in the history
  • Loading branch information
ozh committed Feb 7, 2014
1 parent 5947867 commit df8d8e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mysql/ez_sql_mysql.php
Expand Up @@ -241,6 +241,9 @@ function query($query)
{
$this->connect($this->dbuser, $this->dbpassword, $this->dbhost);
$this->select($this->dbname,$this->encoding);
// No existing connection at this point means the server is unreachable
if ( ! isset($this->dbh) || ! $this->dbh )
return false;
}

// Perform the query via std mysql_query function..
Expand Down
3 changes: 3 additions & 0 deletions mysqli/ez_sql_mysqli.php
Expand Up @@ -251,6 +251,9 @@ function query($query)
{
$this->connect($this->dbuser, $this->dbpassword, $this->dbhost, $this->dbport);
$this->select($this->dbname,$this->encoding);
// No existing connection at this point means the server is unreachable
if ( ! isset($this->dbh) || ! $this->dbh->connect_errno )
return false;
}

// Perform the query via std mysql_query function..
Expand Down
3 changes: 3 additions & 0 deletions pdo/ez_sql_pdo.php
Expand Up @@ -215,6 +215,9 @@ function query($query)
if ( ! isset($this->dbh) || ! $this->dbh )
{
$this->connect($this->dsn, $this->user, $this->password);
// No existing connection at this point means the server is unreachable
if ( ! isset($this->dbh) || ! $this->dbh )
return false;
}

// Query was an insert, delete, update, replace
Expand Down

0 comments on commit df8d8e5

Please sign in to comment.