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();
}
?>