You shouldn't have two ways of mapping an association inside a single entity.
Either use objects, or use identifiers (and don't use lazy-loading then). Also, you can always get a reference, if you know that the foreign key is valid, via $product = $em->getReference(Product::class, 4). Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On Wed, Sep 21, 2016 at 12:56 AM, Dennis Fedco <[email protected]> wrote: > When foreign key integer value is already known ... Is it a good practice > to have both methods for: > > - setting foreign ID directly by using its integer value > - setting foreign ID by using the associated Entity > > Example: > $item = new Item(); > > > //setting foreign key by its integer value > > $item->setProductId(4); > > > //setting foreign key via its Doctrine Entity: > > $productEntity = $em->find(Product::class, 4); > > $item->setProduct($productEntity); > > > > Dennis > > -- > 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 https://groups.google.com/group/doctrine-user. > For more options, visit https://groups.google.com/d/optout. > -- 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 https://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
