Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

A Better fix for #3912

  • Loading branch information...
commit ebf72f85e01e4afda51f14960110853eb88bba3e 1 parent f0e4056
Ralph Schindler authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 library/Zend/Db/TableGateway/Feature/SequenceFeature.php
12 library/Zend/Db/TableGateway/Feature/SequenceFeature.php
View
@@ -55,8 +55,9 @@ public function preInsert(Insert $insert)
}
$this->sequenceValue = $this->nextSequenceId();
- if ($this->sequenceValue === null)
+ if ($this->sequenceValue === null) {
return $insert;
+ }
$insert->values(array($this->primaryKeyField => $this->sequenceValue), Insert::VALUES_MERGE);
return $insert;
@@ -64,8 +65,9 @@ public function preInsert(Insert $insert)
public function postInsert(StatementInterface $statement, ResultInterface $result)
{
- if ($this->sequenceValue !== null)
+ if ($this->sequenceValue !== null) {
$this->tableGateway->lastInsertValue = $this->sequenceValue;
+ }
}
/**
@@ -77,7 +79,6 @@ public function nextSequenceId()
$platform = $this->tableGateway->adapter->getPlatform();
$platformName = $platform->getName();
- $sql = '';
switch ($platformName) {
case 'Oracle':
$sql = 'SELECT ' . $platform->quoteIdentifier($this->sequenceName) . '.NEXTVAL FROM dual';
@@ -92,7 +93,7 @@ public function nextSequenceId()
$statement = $this->tableGateway->adapter->createStatement();
$statement->prepare($sql);
$result = $statement->execute();
- $sequence = $result->getResource()->fetch(\PDO::FETCH_ASSOC);
+ $sequence = $result->current();
unset($statement, $result);
return $sequence['nextval'];
}
@@ -106,7 +107,6 @@ public function lastSequenceId()
$platform = $this->tableGateway->adapter->getPlatform();
$platformName = $platform->getName();
- $sql = '';
switch ($platformName) {
case 'Oracle':
$sql = 'SELECT ' . $platform->quoteIdentifier($this->sequenceName) . '.CURRVAL FROM dual';
@@ -121,7 +121,7 @@ public function lastSequenceId()
$statement = $this->tableGateway->adapter->createStatement();
$statement->prepare($sql);
$result = $statement->execute();
- $sequence = $result->getResource()->fetch(\PDO::FETCH_ASSOC);
+ $sequence = $result->current();
unset($statement, $result);
return $sequence['currval'];
}
Please sign in to comment.
Something went wrong with that request. Please try again.