Le 14/01/2015 16:04, Nima Sadjadi a écrit :
This
$item = $em->getReference('Item', $id);
$cart->addItem($item);
has better performance than this?
$item = $em->find('Item', $id);
$cart->addItem($item);
Please advice.
It is a bit faster (assuming you don't initialize the item later, in
which case it is the same). But note that both snippets are not
equivalent. The first case does not check that the id is a valid id. If
it is not, you will get an error when flushing (because of the DB
constraint).
So the first case is not usable when the id comes from an untrusted
source (user input for instance)
--
Christophe | Stof
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.