1
0
mirror of synced 2024-12-17 00:18:42 +03:00
doctrine2/manual/docs/Performance - Internal optimizations - INSERT.php
2007-04-13 21:49:11 +00:00

30 lines
1.3 KiB
PHP

<code type="php">
// lets presume $users contains a collection of new users
// each having 0-1 email and 0-* phonenumbers
$users->save();
/**
* now doctrine would perform prepared queries in the following order:
*
* first the emails since every user needs to get the primary key of their newly created email
* INSERT INTO email (address) VALUES (:address)
* INSERT INTO email (address) VALUES (:address)
* INSERT INTO email (address) VALUES (:address)
*
* then the users
* INSERT INTO entity (name,email_id) VALUES (:name,:email_id)
* INSERT INTO entity (name,email_id) VALUES (:name,:email_id)
* INSERT INTO entity (name,email_id) VALUES (:name,:email_id)
*
* and at last the phonenumbers since they need the primary keys of the newly created users
* INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
* INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
* INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
* INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
* INSERT INTO phonenumber (phonenumber,entity_id) VALUES (:phonenumber,:entity_id)
*
* These operations are considerably fast, since many databases perform multiple
* prepared queries very rapidly
*/
</code>