note 59930 added to function.pdo-lastinsertid
| From: | opikatopikdotru at osu1 dot php dot net | Date: | Tue, 20 Dec 2005 14:10:19 +0000 |
| Subject: | note 59930 added to function.pdo-lastinsertid | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100466@lists.php.net to get a copy of this message | ||
Simple example:
<?php
try {
$dbh = new PDO('mysql:host=localhost;dbname=test', 'root',
'passowd');
$smf = $dbh->prepare("INSERT INTO test (
numer) VALUES (?)");
$a = mt_rand(1, 100);
$smf->bindParam(1, $a, PDO::PARAM_INT);
$smf->execute();
print $dbh->lastInsertId().'<br />';
$a = mt_rand(1, 100);
$smf->bindParam(1, $a, PDO::PARAM_INT);
$smf->execute();
print $dbh->lastInsertId();
$dbh = null;
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.pdo-lastinsertid.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59930
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59930&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59930&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59930&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59930&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59930&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59930&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59930&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59930&report=yes
Search -- http://master.php.net/manage/user-notes.php