[FLOW3-general] defone auto_incement on non primary column
Stephan Schuler
Stephan.Schuler at netlogix.de
Fri Dec 16 10:24:13 CET 2011
Hi Peter.
We very often need some kind auf auto incremented value for
objects that are far away from being persisted. Think about
orders, order verifications an such stuff. You really don't
want to persist them just to be able to show a "verify your
input" page to the user.
We use a IdGenerationService for this. Internally it works
with a model class with an $id property that is annotated
with "@ORM\GeneratedValue". It just creates a new OrderId
object, persists it and returns the value. The OrderId
object gets never exposed by our service.
Because of some Doctrine create/persist/load issues, the
auto increment value is not injected into your model object
and you cannot reload it because you don't know it identifier.
So we had to use \Doctrine\DBAL\Connection::lastInsertId()
(which is no static method) and
\TYPO3\FLOW3\Reflection\ObjectAccess::setProperty() for
That.
Regards,
Stephan Schuler
Web-Entwickler
Telefon: +49 (911) 539909 - 0
E-Mail: Stephan.Schuler at netlogix.de
Website: media.netlogix.de
--
netlogix GmbH & Co. KG
IT-Services | IT-Training | Media
Andernacher Straße 53 | 90411 Nürnberg
Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
E-Mail: info at netlogix.de | Internet: http://www.netlogix.de
netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
Umsatzsteuer-Identifikationsnummer: DE 233472254
Geschäftsführer: Stefan Buchta, Matthias Schmidt
-----Ursprüngliche Nachricht-----
Von: flow3-general-bounces at lists.typo3.org [mailto:flow3-general-bounces at lists.typo3.org] Im Auftrag von Robert Lemke
Gesendet: Freitag, 16. Dezember 2011 09:07
An: General discussion about FLOW3
Betreff: Re: [FLOW3-general] defone auto_incement on non primary column
Hi Peter Russ,
On 15.12.2011, at 23:16, Peter Russ wrote:
> I have the following challenge to define an attribute which auto_increments but shouldn't be primary key. So far I haven't found a way to achive this in Doctrine.
This is not possible - but not due to Doctrine's limitations but due to how auto increments work: MySQL only allows auto increments for primary keys ...
Cheers,
Robert
_______________________________________________
FLOW3-general mailing list
FLOW3-general at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
More information about the FLOW3-general
mailing list