- Moderated by:
- Support Team
-
- rank:
-
Helper
- registered:
- November 2004
- Status:
- offline
- last visit:
- 12.03.07
- Posts:
- 387
I have a module that tracks proposals submitted to us. Each proposal is assigned a pid when it's entered. (pid being an auto-incremented value.) I follow the example module's use of GenId to get the next id for pid. I've tried to use the same variable for another field in the table, but I'm just getting a 0. (I'd explain why I need to do this, but it would just increase my annoyance at having to do it, and really I think this is the easier way, which is sad.)
Is it possible to use GenId in this situation to get the number I'm looking for, or am I going to just have to update it after entering the information? -
- rank:
-
Helper
- registered:
- November 2002
- Status:
- offline
- last visit:
- 29.05.07
- Posts:
- 203
GenID is only used to get the next available id on databases that don't support the AUTOINCREMENT property (like Oracle). The only reason you need to use it in your module is to ensure portability. On MySQL, it returns zero. To get the last inserted ID from MySQL, use PO_INSERT_ID after you insert.
See this thread.
It's also explained in my Anatomy document in the example_adminapi_create() section.
