- Messages
- 562
- Reaction score
- 1
- Points
- 18
Hi
I don't know if I can do what I'm asking for and if I can, I don't know where to find the info.
To make it short, I have a script that creates a database entry but needs to refer to it right after. But I cannot know the info it will insert in advance. How can I get that entry's id?
I could simply get the latest id, but I am afraid that the script could be used by two or more people at once and there would be a confusion of the correct entry to use.
Since PHP is server side, is it sufficient to assume that the latest id/entry will be the one created by this very user at this very moment (100% sure) or not? And if not, is there another way to know which entry was just created (since none of the info inserted is unique)?
I used to create a customized secondary id that could be found right away using the variables used to create it, but it's rather inefficient resource-wise considering that the primary id key is already unique and much shorter thanks to the auto increment.
Thanks in advance for the advice!
I don't know if I can do what I'm asking for and if I can, I don't know where to find the info.
To make it short, I have a script that creates a database entry but needs to refer to it right after. But I cannot know the info it will insert in advance. How can I get that entry's id?
I could simply get the latest id, but I am afraid that the script could be used by two or more people at once and there would be a confusion of the correct entry to use.
Since PHP is server side, is it sufficient to assume that the latest id/entry will be the one created by this very user at this very moment (100% sure) or not? And if not, is there another way to know which entry was just created (since none of the info inserted is unique)?
I used to create a customized secondary id that could be found right away using the variables used to create it, but it's rather inefficient resource-wise considering that the primary id key is already unique and much shorter thanks to the auto increment.
Thanks in advance for the advice!