Closed marios88 closed 1 year ago
Thanks for the clear example.
This happens because RedBeanPHP uses a fast 1-pass array_diff() operation to determine which beans to delete, update and add. With non-exclusive lists, this would probably not be a problem. This is a limitation of RedBeanPHP. A workaround might be: $person->xownPhonenumberList[$phone1->id]->number = 11;
Not sure if I can do anything about it in the short term, there is no simple fix for this (without breaking a lot of stuff).
own
works but the queries are funny
UPDATE `phonenumber` SET `number` = 1 , `type` = 'mobile' , `person_id` = NULL WHERE id = 1
UPDATE `phonenumber` SET `number` = 11 , `type` = 'mobile' , `person_id` = 1 WHERE id = 1
To make sure we are on the same page, the method responsible for this is
The workaround you provided works as expected but unfortunately does not fit my current requirements. For now i wrap it up a transaction like this, without touching the xOwn list
R::begin();
...
R::store($phone1);
unset($person[$phone2->id]); // or R::trash();
R::store($person);
...
//run validation
...
if($validation === true){
R::commit();
}else{
R::rollback();
}
Why not simply modify the bean in-place? That would be the RedBean-way I guess...
Thanks, i will look into it and reopen if needed!
Please see the attached code snippet as explaining the issue is a bit hard.