【发布时间】:2011-12-01 11:16:33
【问题描述】:
我有一个 Symfony2 CLI 脚本正在运行,它应该每 3 秒更新一次时间戳。
问题是:$this->em->persist($processInfo) 每次执行时都会在数据库中创建一个新条目。我希望它更新,而不是在每个周期创建。
$processInfo = new ....ProcessInfo();
while(true){
$someObject = new ..();
$this->em()->persist($someObject);
$this->em()->clear(); // sorry forgot this line in my initial question
$processInfo->setLastCheckOn($now); // to know if the script is still running, we set a timestamp in the db
$this->em()->persist($processInfo);
$this->em()->flush();
sleep(3);
}
有什么想法吗?
【问题讨论】:
标签: php symfony doctrine-orm command-line-interface