PHP 使用 POD 访问mysql数据库,如何返回上一个插入记录的自增编号ID string PDO::lastInsertId ([ string $name = NULL ] ) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?php try { $dbh = new PDO('mysql:host=localhost;dbname=test', 'username', 'password'); $stmt = $dbh->prepare("INSERT INTO test (name, email) VALUES(?,?)"); try { $dbh->beginTransaction(); $tmt->execute( array('user', '[email protected]')); $dbh->commit(); print $dbh->lastInsertId(); } catch(PDOExecption $e) { $dbh->rollback(); print "Error!: " . $e->getMessage() . "</br>"; } } catch( PDOExecption $e ) { print "Error!: " . $e->getMessage() . "</br>"; } ?> 请教php抓取页面的问题 一个基础的php+ajax问题 PHP form提交 新手求教 如何随机获取mysql中的任意一条记录? 找几个好用漂亮点的的 PHP Blog。 用哪个比较好? php+ajax的数据时时显示问题 like ‘%” $search "%';‘%” 什么意思? 请问MATCH (co1,co2) AGAINST ('$a')怎样使用? 急求帮助,后天答辩 请php大师详细解说下面代码具体流程 PHP 中的问题 mysqli->fetch_assoc问题
try {
$dbh = new PDO('mysql:host=localhost;dbname=test', 'username', 'password'); $stmt = $dbh->prepare("INSERT INTO test (name, email) VALUES(?,?)"); try {
$dbh->beginTransaction();
$tmt->execute( array('user', '[email protected]'));
$dbh->commit();
print $dbh->lastInsertId();
} catch(PDOExecption $e) {
$dbh->rollback();
print "Error!: " . $e->getMessage() . "</br>";
}
} catch( PDOExecption $e ) {
print "Error!: " . $e->getMessage() . "</br>";
}
?>