What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hello guys, Please take a look of this code. I want to update the data, But it's giving me this erro

U03DBF2H9DY
U03DBF2H9DY Posts: 61 πŸ§‘πŸ»β€πŸš€ - Cadet

Hello guys, Please take a look of this code. I want to update the data, But it's giving me this error. Could you help me in it?

Comments

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βš–οΈ - Guardians (admin)

    The exception says there is already an entry with the same value in the table

  • U03DBF2H9DY
    U03DBF2H9DY Posts: 61 πŸ§‘πŸ»β€πŸš€ - Cadet

    Yes, And I want update that value.

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 πŸ§‘πŸ»β€πŸš€ - Cadet

    Seems that the SchoolTransfer doesn't have the idSchool property set. You probably want to update an existing school in db instead of creating a new one. But without the id being set, it doesn't know which entity to update and rather will create another one.

  • U03DBF2H9DY
    U03DBF2H9DY Posts: 61 πŸ§‘πŸ»β€πŸš€ - Cadet

    idSchool is available there.

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βš–οΈ - Guardians (admin)

    either that what Kay says or the saveSchool implementation is not differentiating between create and update

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 πŸ§‘πŸ»β€πŸš€ - Cadet

    I'd suggest to debug into SchoolFacade. Should be easy to find out.

  • U03DBF2H9DY
    U03DBF2H9DY Posts: 61 πŸ§‘πŸ»β€πŸš€ - Cadet

    How can I update those value?

  • U03DBF2H9DY
    U03DBF2H9DY Posts: 61 πŸ§‘πŸ»β€πŸš€ - Cadet

    Ok.

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 πŸ§‘πŸ»β€πŸš€ - Cadet

    Another reason might be a unique constraint on the name column.

  • U03DBF2H9DY
    U03DBF2H9DY Posts: 61 πŸ§‘πŸ»β€πŸš€ - Cadet

    Is it right for update functionality?

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 πŸ§‘πŸ»β€πŸš€ - Cadet

    Please get familiar with debugging instead of posting dumps.

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 πŸ§‘πŸ»β€πŸš€ - Cadet

    And check the schema.xml file for a unique constraint on the name column and remove, if you don't need it.

  • U03DBF2H9DY
    U03DBF2H9DY Posts: 61 πŸ§‘πŸ»β€πŸš€ - Cadet

    Ok.

  • U03DBF2H9DY
    U03DBF2H9DY Posts: 61 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited June 2022

    I have removed the unique constraint but it still giving me same error.

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βš–οΈ - Guardians (admin)

    the unique constraint seems to be not your main problem. if you updated the schema-file you should not forget to run propel:install

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βš–οΈ - Guardians (admin)

    please look for SchoolFacade.php - there must be a method saveSchool

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βš–οΈ - Guardians (admin)

    which likely uses the entityManager directly or a writer-helper class

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 βš–οΈ - Guardians (admin)

    and please, like Kay mentioned: get familiar how to use xdebug in visual studio code