使用原则2和代码点火器2保存实体的正确方法是什么?


what is the right way to save an entity using doctrine 2 and code igniter 2

我是否在控制器中创建一个新实体,并设置我在$POST上收到的所有字段,或者有一种自动的方式来做到这一点?

你的帖子信息有点少,但通常情况下,是的,你必须隐式创建一个新实体

$entity = new Entity;
$entity->setFoo($bar);
$this->entityManager->persist($entity);
$this->entityManager->flush();