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

the `$db->insertID()` is great,
but when using insertBatch() I cant get it in array

or you have any suggestion?

(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.

May I kindly ask why you need insertBatch() ? Can you please share some code if possible?

Theme © iAndrew 2016 - Forum software by © MyBB