Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for $sth->last_insert_id() #61

Open
pali opened this issue Sep 27, 2019 · 2 comments
Open

Add support for $sth->last_insert_id() #61

pali opened this issue Sep 27, 2019 · 2 comments

Comments

@pali
Copy link
Contributor

pali commented Sep 27, 2019

DBI API since version 1.642 has support for last_insert_id also for statement handle (not only database handle), see: https://metacpan.org/pod/DBI#last_insert_id1

It would be nice if DBD::Pg supports and implement this method.

Difference between $dbh->last_insert_id and $sth->last_insert_id is that $dbh's one returns last global insert id and $sth's one returns insert id for the last executed query by $sth.

@turnstep
Copy link
Contributor

Given the way that DBD::Pg interacts between $sth and $dbh, I don't see a way to make $sth->last_insert_id different from $dbh->last_insert_id. But maybe that's ok. I added some tests for $sth->last_insert_id in 2b11c6d

If you can think of a way to differentiate the two, please update this issue.

@dboehmer
Copy link

Is it feasible to call $dbh->last_insert_id after every query and store its value in the $sth?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants