1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-18 11:51:18 +02:00

DibiMysqlDriver & DibiPostgreSql: escape() checks if resource is alive [Closes #46]

This commit is contained in:
David Grudl
2012-01-19 03:04:21 +01:00
parent 660a9db522
commit 5efb11d780
2 changed files with 12 additions and 0 deletions

View File

@@ -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) . "'";