How can I fetch the last row I inserted using DBI?

后端 未结 3 399
臣服心动
臣服心动 2020-12-17 07:39

How can I fetch the last row that was inserted using DBI (DBD::mysql)?

Code sample:

my $sth = $dbh->prepare(\'INSERT INTO a ( x, y, z ) VALUES ( ?         


        
3条回答
  •  没有蜡笔的小新
    2020-12-17 08:34

    This is a property of the statement handle. You should be able to access the ID like that:

    $sth->{mysql_insertid}
    

提交回复
热议问题