php 使用 pod 访问mysql数据库,如何返回上一个插入记录的自增编号id
php 使用 pod 访问mysql数据库,如何返回上一个插入记录的自增编号id
分享到: 更多
------解决方案--------------------
string pdo::lastinsertid ([ string $name = null ] )
------解决方案--------------------
prepare(insert into test (name, email) values(?,?));
try {
$dbh->begintransaction();
$tmt->execute( array('user', 'user@example.com'));
$dbh->commit();
print $dbh->lastinsertid();
} catch(pdoexecption $e) {
$dbh->rollback();
print error!: . $e->getmessage() . ;
}
} catch( pdoexecption $e ) {
print error!: . $e->getmessage() . ;
}
?>
