In a Windows Server 2008 installation, PostgreSQL database, I have the following piece of code in PHP:
$this->con->beginTransaction();
try {
$stmt = $this->con->prepare(
'INSERT INTO sedoc.proc_dest(id_categoria, ci)'
. ' VALUES (:categoria, :ci)'
);
$stmt->bindValue(':ci', trim($procdestModel->getCI()));
$stmt->bindValue(':categoria', $categoria);
$stmt->execute();
$ultimo = $this->con->lastInsertId('proc_dest_id_proc_dest_seq');
this->con->commit();
return $ultimo;
} catch (Exception $e) {
$this->con->rollBack();
Message::setMessage('registro', 'Error!', 'error');
return false;
}
Successfully insert the record in the table, but lastInsertId
returns nothing. The issue is that I need that courage to continue working with him.
The name of the sequence is correct ... It is BEFORE the commit ... if I remove the transaction, it continues with the same behavior.
Any idea what is happening?