如果我使用 DBI/DBD,如何从 Perl 调用 mysql 函数(如 mysql_insert_id)? [英] How can I call a mysql function (like mysql_insert_id) from Perl if i'm using DBI/DBD?

查看:41
本文介绍了如果我使用 DBI/DBD,如何从 Perl 调用 mysql 函数(如 mysql_insert_id)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
如何获取我插入的最后一行使用DBI?

我需要能够在 mysql 中调用函数.一个例子是:

I need to be able to call functions in mysql. One example is:

$dbh = DBI->connect(......)
$sqlQuery = "INSERT INTO xxx VALUES ......";
$sth = $dbh->prepare($sqlQuery);
$sth->execute();

#The missing code is here
#Call the function mysql_insert_id to retrieve the id of the last inserted record
#Do something with the id

我该怎么做?

推荐答案

from perldoc DBI:

$rv = $dbh->last_insert_id($catalog, $schema, $table, $field);

这篇关于如果我使用 DBI/DBD,如何从 Perl 调用 mysql 函数(如 mysql_insert_id)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆