Answer the question
In order to leave comments, you need to log in
I can't display the last value of the id column, what's wrong?
Help to display the last value of the id column here is the code but it does not work thanks in advance
$result = $db->lastInsertRowid('id');
foreach($result as $row) {
print $row['id'];
# code...
}
Answer the question
In order to leave comments, you need to log in
In the case of SQLite, the lastInsertId function immediately returns a number:
$query = "insert into tbl (name) values (?);";
$stmt = $pdo->prepare($query);
$stmt->execute(['jfjd']);
print 'lastInsertId: ' . $pdo->lastInsertId();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question