diff --git a/dibi/drivers/mysql.php b/dibi/drivers/mysql.php index a536467..66b750c 100644 --- a/dibi/drivers/mysql.php +++ b/dibi/drivers/mysql.php @@ -300,9 +300,15 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiResultDriv { switch ($type) { case dibi::TEXT: + if (!is_resource($this->connection)) { + throw new DibiException('Lost connection to server.'); + } return "'" . mysql_real_escape_string($value, $this->connection) . "'"; case dibi::BINARY: + if (!is_resource($this->connection)) { + throw new DibiException('Lost connection to server.'); + } return "_binary'" . mysql_real_escape_string($value, $this->connection) . "'"; case dibi::IDENTIFIER: diff --git a/dibi/drivers/postgre.php b/dibi/drivers/postgre.php index e8741e6..a04b466 100644 --- a/dibi/drivers/postgre.php +++ b/dibi/drivers/postgre.php @@ -277,6 +277,9 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr switch ($type) { case dibi::TEXT: if ($this->escMethod) { + if (!is_resource($this->connection)) { + throw new DibiException('Lost connection to server.'); + } return "'" . pg_escape_string($this->connection, $value) . "'"; } else { return "'" . pg_escape_string($value) . "'"; @@ -284,6 +287,9 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr case dibi::BINARY: if ($this->escMethod) { + if (!is_resource($this->connection)) { + throw new DibiException('Lost connection to server.'); + } return "'" . pg_escape_bytea($this->connection, $value) . "'"; } else { return "'" . pg_escape_bytea($value) . "'";