【发布时间】:2013-12-27 03:32:00
【问题描述】:
我们有这样的存储库
class CronInfoCharacterInfoRepository extends EntityRepository
{
/**
* @param string|integer $characterID
* @return void
*/
public function add($characterID)
{
if (!$this->find($characterID)) {
$oEntry = new CronInfoCharacterInfo();
$oEntry->setCharacterID($characterID);
$this->getEntityManager()->persist($oEntry);
$this->getEntityManager()->flush();
}
}
}
但我想通过 DQL 插入新条目。我怎样才能通过 $this->createQueryBuilder()... 做到这一点?在存储库中使用“实体管理器”是否正常?
【问题讨论】:
标签: symfony doctrine-orm repository