Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

SequenceFeature doesn't set lastInsertValue correctly #142

Closed
GeeH opened this issue Jun 28, 2016 · 0 comments
Closed

SequenceFeature doesn't set lastInsertValue correctly #142

GeeH opened this issue Jun 28, 2016 · 0 comments
Labels
Milestone

Comments

@GeeH
Copy link
Contributor

GeeH commented Jun 28, 2016

This issue has been moved from the zendframework repository as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html


Original Issue: https://api.github.com/repos/zendframework/zendframework/issues/7689
User: @tiptone
Created On: 2016-03-17T19:23:50Z
Updated At: 2016-06-28T12:45:52Z
Body
In the file Module.php:

$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$featureSet = new FeatureSet();
$featureSet->addFeature(new Feature\SequenceFeature('ID','SEQNAME'));
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new ModeledObject());
return new TableGateway('TABLENAME', $dbAdapter, $featureSet, $resultSetPrototype);

In the file ModelTable.php

$this->tableGateway->insert($data);
$id = $this->tableGateway->lastInsertValue;

Expected:
$id matches the value of TABLENAME.ID after insert.

Result:
$id is the value of TABLENAME.ID before the insert was done. TABLENAME.ID is always +1 higher than the value returned by lastInsertValue.


Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants