-2
你好,我腦水腫的問題這段代碼:監聽週期回調
ListenerCrud.php
<?php
namespace mio\mioBundle;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\ORM\EntityManager;
use mio\mioBundle\Entity\Log;
use Symfony\Component\HttpFoundation\Response;
class ListenerCrud{
public function preUpdate(PreUpdateEventArgs $eventArgs){
if ($eventArgs->getEntity() instanceof Usuario){
$entity = $eventArgs->getEntity();
$entityManager = $eventArgs->getEntityManager();
$log = new Log();
$entityManager->persist($log);
$entityManager->flush();
}
}
}
?>
config.yml:
listenercrud:
class: mio\mioBundle\ListenerCrud
tags:
- { name: doctrine.event_listener, event: preUpdate}
但沒有創建日誌數據庫。幫助我please.thanks
那麼,如何是否被允許同花順更新前更改保存到數據庫?我需要在PostUpdate中保存getOldValue($ fieldName)。謝謝。 – paradita