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.

77<br />

Bulk Inserts with Domain<br />

• Insert 10000 objects batches of 20:<br />

$batchSize = 20;<br />

for ($i = 1; $i setStatus('user');<br />

$user->setUsername('user' . $i);<br />

$user->setName('Mr.Smith-' . $i);<br />

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

if ($i % $batchSize == 0) {<br />

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

$em->clear(); // Detaches all objects from <strong>Doctrine</strong>!<br />

}<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!