Permalink
Browse files

A Better fix for #3912

  • Loading branch information...
1 parent f0e4056 commit ebf72f85e01e4afda51f14960110853eb88bba3e @ralphschindler ralphschindler committed Apr 16, 2013
Showing with 6 additions and 6 deletions.
  1. +6 −6 library/Zend/Db/TableGateway/Feature/SequenceFeature.php
@@ -55,17 +55,19 @@ 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;
}
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'];
}

0 comments on commit ebf72f8

Please sign in to comment.