Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在symfony中执行flush()之前或之后获取sql插入/更新查询_Symfony_Doctrine - Fatal编程技术网

如何在symfony中执行flush()之前或之后获取sql插入/更新查询

如何在symfony中执行flush()之前或之后获取sql插入/更新查询,symfony,doctrine,Symfony,Doctrine,我想这样做: //insert $entity = new House(); $entity->setName('5 Stars'); $entity->setAddress('Something'); $em->persist($entity); //or a update $entity->setName('New Name'); $em->persist($entity); 现在函数就来了 $em->flush(); 我不知道它是在flush()之前

我想这样做:

//insert
$entity = new House();
$entity->setName('5 Stars');
$entity->setAddress('Something');
$em->persist($entity);
//or a update
$entity->setName('New Name');
$em->persist($entity);
现在函数就来了

$em->flush();

我不知道它是在flush()之前还是之后,以及如何执行,但我想获得将要执行的查询,以将数据保存到数据库中

非常简单,您需要使用条令生命周期事件,在您的情况下,它是-'preFlush','onFlush','postfush'


请参见

也许您应该告诉我们您打算如何处理该查询?我想创建实体的历史记录,为此我需要获取查询(从…更新或插入到…)