Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6967701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:21:20+00:00 2026-05-27T16:21:20+00:00

Having an issue with update one-to-many relationships with CodeIgniter/Datamapper. In my mind I had

  • 0

Having an issue with update one-to-many relationships with CodeIgniter/Datamapper. In my mind I had the notion that when a one-to-many relationship was updated. The existing records within the relationship table would be removed and the new relationships added. This appears not to be the case.

Using the following, adds new records to the relationship table each time:

$item->save($banners);

The relationships that are created are correct but I was expecting only the objects contained within $banners to be included in the relationship table not any historial items.

Is this correct functionality and if so what is the best method for making this update process work?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:21:21+00:00Added an answer on May 27, 2026 at 4:21 pm

    One-to-many doesn’t mean “only one can be related”. See Wikipedia

    It just means that the “one” side of the relationship contains the foreign key.

    You need to manually reset existing relations if you want this behaviour. This goes quickest using an update query where you set ‘foreign_key’ to NULL where ‘foreign_key’ is the ‘id’ value of the object to be related.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having issue with Action Listener of a JTable that being updated according the
Having an issue here that I have tried everything I can think of but
I'm having an issue with a query that currently uses LEFT JOIN weblog_data AS
I am having a really hard time updating and deleting many to many relationships
i am having trouble getting this to work, can any one spot the issue?
I am having an issue that is stumping me. I have a relatively simple
I am having this issue and I am hoping that it is so simple
I'm having issues getting Firefox to update a webpage when its class is changed
I am having issues with ADO.NET 2.0 merging/importing data. I need to update/insert data
I'm having some issues using mysqli to execute a script with SELECT,DELETE,INSERT and UPDATE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.