更新是否有可能在如下类似的方式更新实体:学说2从实体
$data = new ATest(); // my entity
$data->id = 1; // id 1 already exists, I just want to update this row
$data->name = "ORM Tested"; // changed the name
$entityManager->persist($data);
$entityManager->flush();
这将插入,改变对象的ID,而不是在数据库中更新现有行。
你怎么能手动设置ID? ID不是受保护的财产吗? – 2014-06-11 12:05:42
不,不,如果你不做它 – Eagle1 2015-02-12 18:58:42