$result = $db->lastInsertRowid('id');
foreach($result as $row) {
print $row['id'];
# code...
}
$query = "insert into tbl (name) values (?);";
$stmt = $pdo->prepare($query);
$stmt->execute(['jfjd']);
print 'lastInsertId: ' . $pdo->lastInsertId();