Doctrine ORM One to Many Relationship (bidirectional)

Поділитися
Вставка
  • Опубліковано 19 вер 2024

КОМЕНТАРІ • 18

  • @flair03
    @flair03 3 роки тому

    Very well explained and very helpful. Thanks!

  • @olegandru9522
    @olegandru9522 9 місяців тому

    Hello. I want to get the products as they are at 15:06, but I saw that each product has a "manufacturer" property, which contains a "Manufacturer" object (after the id, name). But if I expand this Manufacturer object, then it contains a complete list of products, because the manufacturer class has the inverse property relation of products products(5:22).... But in the list of products (15:06) I do NOT need a list of all products again loaded in each Manufacturer object (If we expand this object, we will see the products property which is an array of products). This is strange, because it turns out that we get an array of products, and inside each product we again load the full list of products (because it is in each Manufacturer in the product). Can I get a list of all the manufacturer's products without duplicating the products inside the Manufactor object?

  • @CaimAstraea
    @CaimAstraea 2 роки тому

    What shortcut did you use for getters and setters in phpstorm ? The shortest path I could find was cmd + N but I still have an extra step while you jumped straight into the window :D

    • @GaryClarkeTech
      @GaryClarkeTech  2 роки тому

      Ctrl + enter pulls up the menu
      Then just select getters and setters...then choose the properties you want to create for

  • @Hunterrr15
    @Hunterrr15 3 роки тому

    Thanks for video, it helped me understand topic :)

  • @MrWilde
    @MrWilde 3 роки тому

    I was under the impression there is no functionality difference between Symfony 5 and 4, just the deprecated items removed in 5. There are some things I saw in this vide not in Symfony 4, liked the mappedBy in the oneToMany relationShip. Is this more of a doctrine version issue?
    Just an FYI the content is great but it is a ittle hard to follow, jumping between pages very quickly and editing code and the bottom of the page can be hard to see. Just some feedback, but the content is really good.

    • @GaryClarkeTech
      @GaryClarkeTech  3 роки тому

      Yes mappedBy..and all the annotations are a Doctrine thing...not directly Symfony related.

  • @RomskieL
    @RomskieL Рік тому

    I'm currently trying this out in Symfony 6. The cascade={"persist"} will give me an error, so I tried cascade: ['persist']. It didn't give me an error, but it won't cascade in saving the child. I still need to persist the parent and persist also the child to save them both into the db.

    • @RomskieL
      @RomskieL Рік тому

      I got it now. Instead of adding the parent to the child: $child->setParent($parent), I added the child to the parent: $parent->addChild($child). It then cascaded the persist.

    • @GaryClarkeTech
      @GaryClarkeTech  Рік тому

      @@RomskieL Great stuff...I'm glad you managed to figure it out..well done!

  • @lorandgyorgy-fazakas11
    @lorandgyorgy-fazakas11 2 роки тому

    Is there a way to setup a relation only by id? (in that case manufacturer_id)

    • @GaryClarkeTech
      @GaryClarkeTech  2 роки тому +1

      It's all fairly configurable. I stick to common conventions as much as I can.

  • @TheMefizz
    @TheMefizz 3 роки тому

    thx