I'm trying to redeem the last id
on the bank with lastInsertId()
of the PDO, but nothing appears.
OBS: I'm using Postgre.
<?php
try {
$dbh = new PDO('pgsql:host=localhost;port=5432;dbname=bancocjweb1', 'postgres', '12345');
$stmt = $dbh->prepare("INSERT INTO pessoas (sexo, nascimentodata, email, nome, cpf) VALUES(?,?,?,?,?)");
try {
$dbh->beginTransaction();
$stmt->execute(array(
'm',
'1987-01-01',
'[email protected]',
'teste',
'05255178910'
));
$dbh->commit();
echo $dbh->lastInsertId();
}
catch (PDOExecption $e) {
$dbh->rollback();
print "Error!: " . $e->getMessage() . "</br>";
}
}
catch (PDOExecption $e) {
print "Error!: " . $e->getMessage() . "</br>";
}
?>