Well, I think I am discovering something: Actually in my editInfo.php page
I have a form to edit fields then after submitting I have this:
if (isset($_POST['do']) && $_POST['do'] == "edit") {
$object = $em->find('Entities\Info', $_POST['id']);
if ($object !== null) {
$object->setFields($_POST, array(....));
$em->persist($object);
if (isset($_POST['update_list']) && $_POST['update_list']
== "1") {
$somethings =
$em->getRepository('Entities\Something')->findBy(array('productId' =>
$_POST['productId']));
foreach ($somethings as $something) {
$something->setFields($_POST,
array(...));
}
}
$em->flush();
}
}
Info table will be updated with no problem but if update_list checkbox on
form is checked, these values should be updated in Something entity/table
too as you see above.
The mapping from Info to Something is OneToMany and from Something to Info
is ManyToOne, and I am pretty sure that should be a correct mapping.
In Something entity I have this mapping:
$metadata->mapManyToOne(array( 'fieldName' => 'info',
'targetEntity' => 'Entities\\Info',
'inversedBy' => 'somethings',
'joinColumns' => array( 0 => array( 'name'
=> 'product_id',
'referencedColumnName' => 'product_id',
'nullable' => true,
'columnDefinition' => NULL,
), )
));
and the mapping in Info entity is this:
$metadata->mapOneToMany(array( 'fieldName' => 'somethings',
'targetEntity' => 'Entities\\Something',
'mappedBy' => 'info',
'joinColumns' => array( 0 => array( 'name'
=> 'product_id',
'referencedColumnName' => 'product_id',
'nullable' => true,
'columnDefinition' => NULL,
), )
));
Assuming this ManyToOne/OneToMany relationship is correct, I guess I am
trying to update the somethings entities somehow wrong? How should I update
it?
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.