本文整理匯總了PHP中Doctrine\ORM\EntityManagerInterface::clear方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityManagerInterface::clear方法的具體用法?PHP EntityManagerInterface::clear怎麽用?PHP EntityManagerInterface::clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ORM\EntityManagerInterface
的用法示例。
在下文中一共展示了EntityManagerInterface::clear方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: purgeDatabase
/**
* @BeforeScenario
*/
public function purgeDatabase()
{
$this->entityManager->getConnection()->getConfiguration()->setSQLLogger(null);
$purger = new ORMPurger($this->entityManager);
$purger->purge();
$this->entityManager->clear();
}
示例2: startJobs
/**
* {@inheritdoc}
*/
public function startJobs(ProjectInterface $project)
{
$query = 'UPDATE Worldia\\Bundle\\TextmasterBundle\\Entity\\Job j ' . 'SET j.status = :status ' . 'WHERE j.projectId = :projectId ';
$q = $this->entityManager->createQuery($query)->setParameter('status', JobInterface::STATUS_STARTED)->setParameter('projectId', $project->getId());
$q->execute();
$this->entityManager->clear();
}
示例3: purgeDatabase
/**
* @BeforeScenario
*/
public function purgeDatabase()
{
if (null === $this->entityManager) {
throw new \RuntimeException('Cannot purge database. Entity manager is not set');
}
$this->entityManager->getConnection()->getConfiguration()->setSQLLogger(null);
$purger = new ORMPurger($this->entityManager);
$purger->purge();
$this->entityManager->clear();
}
示例4: getEntityManager
/**
* @return EntityManagerInterface
* @throws \PHPUnit_Framework_SkippedTestError
* @throws \InvalidArgumentException
* @throws \Doctrine\ORM\ORMException
*/
public static function getEntityManager()
{
if (null === self::$entityManager) {
if (!extension_loaded('ibm_db2')) {
throw new \PHPUnit_Framework_SkippedTestError('DB2 connection is unavailable, skipping test');
}
$configuration = Setup::createAnnotationMetadataConfiguration([__DIR__ . '/entity/'], true);
if (!file_exists(__DIR__ . '/config/local.php')) {
throw new \PHPUnit_Framework_SkippedTestError('test/config/local.php not found');
}
$connection = (require __DIR__ . '/config/local.php');
self::$entityManager = EntityManager::create($connection, $configuration);
}
self::$entityManager->clear();
return self::$entityManager;
}
示例5: removeVisitor
/**
* @param $ticketDetail
*/
private function removeVisitor()
{
self::$entityManager->clear();
$ticketDetail = self::$entityManager->getRepository('AppBundle:TicketDetail')->find(self::$ticketDetailId);
$visitor = $ticketDetail->getVisitor();
$ticketDetail->setVisitor();
self::$entityManager->remove($visitor);
self::$entityManager->flush();
}
示例6: finishBatch
/**
* @param array $selectedIds
* @param string $value
*
* @return int
*/
protected function finishBatch(array &$selectedIds, $value)
{
$qBuilder = $this->entityManager->createQueryBuilder();
$entitiesCount = $qBuilder->update($this->entityName, 'e')->set('e.' . $this->fieldName, ':value')->where($qBuilder->expr()->in('e.' . $this->identifierName, $selectedIds))->getQuery()->setParameter('value', $value)->execute();
$this->entityManager->flush();
if ($this->entityManager->getConnection()->getTransactionNestingLevel() == 1) {
$this->entityManager->clear();
}
$selectedIds = [];
return $entitiesCount;
}
示例7: orderHasTheFollowingProducts
/**
* @Given /^order "([^"]*)" has the following products:$/
*
* @param $orderNumber
* @param TableNode $table
*/
public function orderHasTheFollowingProducts($orderNumber, TableNode $table)
{
/** @var OrderInterface $order */
$order = $this->orderRepository->findOneBy(['number' => $orderNumber]);
foreach ($table->getHash() as $row) {
$product = $this->productRepository->findOneByName($row['name']);
/** @var OrderItemInterface $orderItem */
$orderItem = $this->orderItemFactory->createNew();
$orderItem->setVariant($product->getFirstVariant());
$order->addItem($orderItem);
}
$this->entityManager->flush();
$this->entityManager->clear();
}
示例8: clear
public function clear()
{
$this->em->clear();
}
示例9: clear
/**
*
*/
public function clear()
{
$this->entityManager->clear();
}
示例10: clean
protected function clean()
{
$em = $this->em;
$reflectedEm = new \ReflectionClass($em);
if ($reflectedEm->hasProperty('repositories')) {
$property = $reflectedEm->getProperty('repositories');
$property->setAccessible(true);
$property->setValue($em, []);
}
$this->em->clear();
}
示例11: flush
/**
* Flush and clear the entity manager
*/
public function flush()
{
$this->entityManager->flush();
$this->entityManager->clear($this->entityName);
}
示例12: clear
public function clear()
{
$this->entityManager->clear();
$this->fingersCrossedHandler->clear();
}
示例13: findAllEntity
private function findAllEntity(EntityManagerInterface $em, $label)
{
$times = 100;
$size = 50;
$startPersist = microtime(true);
$rep = $em->getRepository(Country::CLASSNAME);
echo PHP_EOL . $label;
for ($i = 0; $i < $size; $i++) {
$em->persist(new Country("Country {$i}"));
}
$em->flush();
$em->clear();
printf("\n[%s] persist %s countries", number_format(microtime(true) - $startPersist, 6), $size);
$startFind = microtime(true);
for ($i = 0; $i <= $times; $i++) {
$list = $rep->findAll();
$em->clear();
$this->assertCount($size, $list);
}
printf("\n[%s] find %s countries (%s times)", number_format(microtime(true) - $startFind, 6), $size, $times);
printf("\n%s\n", str_repeat('-', 50));
}
示例14: next
/**
* We need to clear identity map before navigating to next record.
*/
public function next()
{
$this->manager->clear();
parent::next();
}
示例15: flushAndClearEntityManager
/**
* @return void
*/
private function flushAndClearEntityManager()
{
$this->entityManager->flush();
$this->entityManager->clear();
}