Hi,
I'm using Phalcon's ORM for interacting with an Oracle DB. I'm trying to set it up so that when I instantiate a new object and store it in the DB then the model object will automatically get it's ID property populated with the auto-generated ID that Oracle assigned for the new record.
I couldn't find any clear documentation about how to acheive this. Facts I managed to collect are:
- Phalcon can do this, but not for all DBs. It seems that it doesn't do it with Oracle.
- When Phalcon doesn't support the DB then we can acheive this by adding getSequenceName() model to the model. This method should return the name of the sequence. This is assuming that supportSequences() returns true (which it does for me).
- Some DBs require putting the sequence name in quotes - https://github.com/phalcon/cphalcon/issues/2376
- Not sure how this can help, but it seems related... https://stackoverflow.com/questions/21009695/working-with-oracle-sequences-in-phalcon
So, I tried to use all the above info in order to make it happen, but I have a feeling I'm missing something. Don't know what though.
Can anyone post an example of how to make this work?
Thanks! :)