11.12.2012 Views

Zend Framework 1 + Doctrine 2

Zend Framework 1 + Doctrine 2

Zend Framework 1 + Doctrine 2

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

50<br />

Transactions<br />

• Explicit:<br />

// $em instanceof EntityManager<br />

$em->getConnection()->beginTransaction(); // suspend auto-commit<br />

try {<br />

//... do some work<br />

$user = new User;<br />

$user->setName('George');<br />

$em->persist($user);<br />

$em->flush();<br />

$em->getConnection()->commit();<br />

} catch (Exception $e) {<br />

$em->getConnection()->rollback();<br />

$em->close();<br />

throw $e;<br />

}<br />

<strong>Zend</strong> <strong>Framework</strong> 1 + <strong>Doctrine</strong> 2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!