To get the correct id back from PDO::lastInsertId(), you have to call it before the commit.
e.g. somthing like...
$dbh = new PDO();
$dbh->beginTransaction();
$stmt = $dbh->prepare($sql);
$stmt->execute($params);
$return = $dbh->lastInsertId();
$dbh->commit();
...will work nicely
No comments:
Post a Comment