0
How do I register in the same database table using beginTransaction(). Example: Registering various details of a product
$entityManager->getConnection()->beginTransaction();
try {
...
// ultimo id Produto cadastrado
$ultimo_id = $table->getId()
$num = array(5,2,3);
$lote = array(8,6,7);
// O PROBLEMA é que só cadastra a última (no caso chave [2]). Não entendi
$this->mais_produto($num[0], $lote[0], $ultimo_id);
$this->mais_produto($num[1], $lote[1], $ultimo_id);
$this->mais_produto($num[2], $lote[2], $ultimo_id);
$entityManager->getConnection()->commit();
return true;
}
} catch (\Exception $e) {
$entityManager->getConnection()->rollback();
throw $e;
return false;
}
dasIn the function mais_product() is running the Doctrine functions $entityManager->persist($table); $entityManager->flush();
What the function
mais_produto
ago?– Rodrigo Rigotti
records data in the database, using persist() and flush()
– Geovani Santos
It was not recording because I was running inside an array. The solution was to use the
$entityManager->clear
after the commit.– Geovani Santos