Calling Developers!
We are reenergizing our code contribution process! Learn More

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

Options
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,034 ⚖️ - Guardians (admin)
    Options

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

  • U03DBF2H9DY
    U03DBF2H9DY Posts: 61 🧑🏻‍🚀 - Cadet
    Options

    Yes, And I want update that value.

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 🧑🏻‍🚀 - Cadet
    Options

    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
    Options

    idSchool is available there.

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,034 ⚖️ - Guardians (admin)
    Options

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

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 🧑🏻‍🚀 - Cadet
    Options

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

  • U03DBF2H9DY
    U03DBF2H9DY Posts: 61 🧑🏻‍🚀 - Cadet
    Options

    How can I update those value?

  • U03DBF2H9DY
    U03DBF2H9DY Posts: 61 🧑🏻‍🚀 - Cadet
    Options

    Ok.

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 🧑🏻‍🚀 - Cadet
    Options

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

  • U03DBF2H9DY
    U03DBF2H9DY Posts: 61 🧑🏻‍🚀 - Cadet
    Options

    Is it right for update functionality?

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 🧑🏻‍🚀 - Cadet
    Options

    Please get familiar with debugging instead of posting dumps.

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 🧑🏻‍🚀 - Cadet
    Options

    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
    Options

    Ok.

  • U03DBF2H9DY
    U03DBF2H9DY Posts: 61 🧑🏻‍🚀 - Cadet
    edited June 2022
    Options

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

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,034 ⚖️ - Guardians (admin)
    Options

    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,034 ⚖️ - Guardians (admin)
    Options

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

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,034 ⚖️ - Guardians (admin)
    Options

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

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,034 ⚖️ - Guardians (admin)
    Options

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