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 8546559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:03:27+00:00 2026-06-11T13:03:27+00:00

I have a collection of tables like so: logbook , responsibility , user Responsibilities

  • 0

I have a collection of tables like so:

logbook, responsibility, user

Responsibilities are reused – but only one distinct responsibility per logbook. Each responsibility has one user. A user can have multiple responsibilities (on multiple logbooks). I have a table to join these together:

logbook_responsibility, with three colummns (each making up the primary key) – logbook_id, responsibility_id and user_id, which are all foreign keys. In my schema.xml this table is set isCrossRef="true".

When updating a responsibility to a new user, I am passed in an array in $_POST in the form of $_POST['responsibility'][2] = 5, $_POST['responsibility'][7] = 2, etc. I have a function that is supposed to update them:

public function updateResponsibilities($options = null)
{
  foreach ($options['responsibility'] as $k => $v) {      
    $user = UserQuery::create()
      ->filterByLogbook($this->logbook)
      ->findOneById($v);

    $logbookResponsibility = LogbookResponsibilityQuery::create()
      ->filterByLogbook($this->logbook)
      ->filterByResponsibilityId($k)
      ->findOne();

    if (is_null($user) || is_null($logbookResponsibility)) {
      break;
    }

    $logbookResponsibility->setUser($user)->save();
  }

  return true;
}

Here I loop through the options, create a new user with the supplied ID, filter by the current logbook to make sure they’re allowed to be responsible for this logbook, and grab the first one. This works fine (dumped with ->toArray():

array(11) {
  ["Id"]=>
  int(2)
  ["CompanyId"]=>
  int(1)
  ["CurrentLogbookId"]=>
  int(1)
  ["OtherFieldsHere..."]=>
  // etc, etc

}

Next I grab a LogbookResponsibility, filtering again by the current logbook and the responsibility ID. At this stage the new user ID is shown correctly:

array(3) {
  ["LogbookId"]=>
  int(1)
  ["ResponsibilityId"]=>
  int(1)
  ["UserId"]=>
  int(1)
}

I then update this object with the previously grabbed user, and save. I get no errors doing this, and inspecting the object afterwards shows that the object, at least, has updated:

array(3) {
  ["LogbookId"]=>
  int(1)
  ["ResponsibilityId"]=>
  int(1)
  ["UserId"]=>
  int(2)
}

But, without touching anything else, looking at the database after, the user ID is still 1. I’ve tested running a query like:

UPDATE logbook_responsibility SET user_id = 1 WHERE logbook_id = 1 AND responsibility_id = 1;

…which works without error.

My actual question is two-fold:

1) Why isn’t it saving? (Is it to do with my cross ref table? Is there a problem with cross ref tables with more than 2 columns?)

2) Is there generally a better way to achieve my setup? *(I tried achieving the same with a responsibility object, but didn’t see a way to update the logbook_responsibility from there)*

Happy to take suggestions as well as an actual answer!

  • 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-06-11T13:03:28+00:00Added an answer on June 11, 2026 at 1:03 pm

    As suggested in the comments I used getLastExecutedQuery() to get hold of the actual query run when I run the save() method, and this is the query being run (also explaining why there was no error):

    UPDATE `logbook_responsibility` SET `USER_ID`=3 WHERE
      logbook_responsibility.LOGBOOK_ID=1 AND
      logbook_responsibility.RESPONSIBILITY_ID=1 AND
      logbook_responsibility.USER_ID=3;
    

    As you can see, the update statement is syntactically correct, but the problem seems to lie in how Propel updates primary keys – which leads me to wonder why I have my user id column as part of the primary key?

    It didn’t make sense to have the user as part of the primary key, so I removed it, and of course that made it work. There does still remain the real question, “How do I update primary keys in Propel?”, but that’s better left to somebody else to explain.

    I’ll be happy to un-mark this as the answer if someone has a better explanation.

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

Sidebar

Related Questions

For some background... I have a collection of tables, and I would like a
I have 3 models/tables: User, Task, and TaskInstance. The Task table is like a
I have two tables. I want them be near each other and not like
I have two tables like so: class Collection(models.Model): name = models.CharField() class Image(models.Model): name
I have two tables, one stores user sessions and the other stores shopping cart
I have a table that is a collection entries as to when a user
I have Collection List<Car> . How to compare each item from this collection with
I'm planning to have collection of items stored in a TCollection. Each item will
for example I have collection foo of documents like that: {tag_cloud:[{value:games, count:10}, {value:girls, count:500}]}
I have two tables Boxer and Prospect. Boxers has general stuff like name and

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.