Skip to content

Instantly share code, notes, and snippets.

@dantleech
Last active March 29, 2016 20:04
Show Gist options
  • Select an option

  • Save dantleech/c53749249b24214d200b4f3ea2f10cce to your computer and use it in GitHub Desktop.

Select an option

Save dantleech/c53749249b24214d200b4f3ea2f10cce to your computer and use it in GitHub Desktop.
<?php
$account = new Account();
$account->setName('Company');
$account->setPlaceOfJurisdiction('Feldkirch');
$this->em->persist($account);
$this->em->flush();
// echos "1"
echo $this->em->getConnection()->query('SELECT COUNT(*) FROM co_accounts')->fetchColumn();
$this->em->getConnection()->exec('DELETE FROM co_accounts');
// does nothing
$this->em->refresh($account);
// state is managed
$state = $this->em->getUnitOfWork()->getEntityState($account);
$account->setName('Bas');
$this->em->persist($account);
$this->em->flush();
// echos "0"
echo $this->em->getConnection()->query('SELECT COUNT(*) FROM co_accounts')->fetchColumn(); // 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment