Performance - Internal optimizations - INSERT.php 1.29 KB
Newer Older
doctrine's avatar
doctrine committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<?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
 */
?>