Last active
June 11, 2016 11:14
-
-
Save ktat/69072d306e3916ea1d41ba8333e5d3c7 to your computer and use it in GitHub Desktop.
DBD::mysql mysql_insertid returns 0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## version | |
# Perl 5.18.1 | |
# DBI 1.636 | |
# DBD::mysql 4.033 | |
## create table SQL | |
# create table t(id integer not null auto_increment, primary key (id)) ; | |
## this can get mysql_insertid | |
my $dbh = DBI->connect("dbi:mysql:test;user=root"); | |
my $sth = $dbh->prepare("insert into t() values()"); | |
$sth->execute(); | |
print $dbh->{mysql_insertid} | |
## use ping method before getting mysql_isnertid, mysql_insertid returns 0 | |
my $dbh = DBI->connect("dbi:mysql:test;user=root"); | |
my $sth = $dbh->prepare("insert into t() values()"); | |
$sth->execute(); | |
$dbh->ping; | |
print $dbh->{mysql_insertid} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment