1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-13 01:24:06 +02:00

- DibiPostgreDriver - workaround for bug in pg_affected_rows

- added DibiResult::setObjects([TRUE | FALSE | class name])
This commit is contained in:
David Grudl
2008-05-12 22:55:51 +00:00
parent 7bb5684d71
commit 40e9f313c3
9 changed files with 91 additions and 33 deletions

View File

@@ -217,7 +217,7 @@ class DibiMsSqlDriver extends /*Nette::*/Object implements IDibiDriver
{
// offset suppot is missing...
if ($limit >= 0) {
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
}
if ($offset) {

View File

@@ -231,7 +231,7 @@ class DibiOdbcDriver extends /*Nette::*/Object implements IDibiDriver
{
// offset suppot is missing...
if ($limit >= 0) {
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
$sql = 'SELECT TOP ' . (int) $limit . ' * FROM (' . $sql . ')';
}
if ($offset) throw new InvalidArgumentException('Offset is not implemented in driver odbc.');

View File

@@ -53,7 +53,7 @@ class DibiPdoDriver extends /*Nette::*/Object implements IDibiDriver
/**
* Affected rows.
* @var int
* @var int|FALSE
*/
private $affectedRows = FALSE;
@@ -92,7 +92,7 @@ class DibiPdoDriver extends /*Nette::*/Object implements IDibiDriver
$this->connection = new PDO($config['dsn'], $config['username'], $config['password'], $config['options']);
} catch (PDOException $e) {
throw new DibiDriverException($e->getMessage(), $e->getCode());
throw new DibiDriverException($e->getMessage(), $e->getCode());
}
if (!$this->connection) {

View File

@@ -58,6 +58,13 @@ class DibiPostgreDriver extends /*Nette::*/Object implements IDibiDriver
private $escMethod = FALSE;
/**
* Affected rows.
* @var int|FALSE
*/
private $affectedRows = FALSE;
/**
* @throws DibiException
@@ -144,9 +151,12 @@ class DibiPostgreDriver extends /*Nette::*/Object implements IDibiDriver
$this->resultset = @pg_query($this->connection, $sql);
if ($this->resultset === FALSE) {
$this->affectedRows = FALSE;
throw new DibiDriverException(pg_last_error($this->connection), 0, $sql);
}
$this->affectedRows = pg_affected_rows($this->resultset); // retrieve immediately due PHP bug
return is_resource($this->resultset);
}
@@ -159,7 +169,7 @@ class DibiPostgreDriver extends /*Nette::*/Object implements IDibiDriver
*/
public function affectedRows()
{
return pg_affected_rows($this->resultset);
return $this->affectedRows;
}