Welcome Guest, Not a member yet? Register   Sign In
how to get ID's after insertBatch()?
#2

(This post was last modified: 04-30-2021, 08:52 AM by evansharp.)

This gets asked for a lot and to be honest, I've wished for it myself too. The issue is not just that 'CI does not provide this method', it's that the concept is flawed on the DB side. If another set of inserts or updates hits the DB at the same time, the auto-incrementing ids will get collated. Ultimately I don't blame the dev crew for not wanting to take on the challenge of solving this.

The standard solution, which admittedly has performance tradeoffs, is to run individual inserts in a loop and to collect the insertID with that db connection method each time.
Reply


Messages In This Thread
RE: how to get ID's after insertBatch()? - by evansharp - 04-30-2021, 08:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB