Symfony总是在我的自定义控制台命令中抛出OptimisticLockException

时间:2018-05-10 08:57:54

标签: symfony doctrine

我在控制台命令中的代码

构造

private $em;

public function __construct(EntityManagerInterface $em, $name = null)
{
    parent::__construct($name);

    $this->em = $em;
}

...在我的executte命令中始终是OptimisticLockException

protected function execute(InputInterface $input, OutputInterface $output) {

$repository = $this->em->getRepository(ProductData::class);
$product = $repository->findOneBy(array('code' => $data[0]));

$product->setName($data[1]);
$product->setDesc($data[2]);
$product->setStockLevel((float)$data[3]);
$product->setPrice((float)$data[4]);
$this->em->flush();    }

我需要帮助

0 个答案:

没有答案