Related Table Erroneous Entries
Archived from the Xataface Users forum.
simb — Wed Oct 24, 2012 10:24 am
Hi Steve and forum members,
I hope someone can shed light on __keys__[id] a hidden field which is passed when submitting a form.
The issue we are facing is that in a related table arrangement, the __keys__[id] at some random point in time do not match the actual id of the table. As a result the related data which gets entered is for a wrong parent record.
Here is the source view of the page before submission:
The actual value that should have been passed is 729 but what is passed is 730 ( __keys__[id]) and as a result the data gets entered in the wrong parent record. Really scratching my head and there just does not seem to be a logical answer to this - Did not change the code etc, every thing was working just a few days ago and the recurrence of the event is more than can be safely ignored. Currently handling this in beforeInsert when I manually check the values and if they are different, exit gracefully. This happens in all related tables and with admin as well other roles.
Any pointers will be highly appreciated,
Looking forward -
Thanks!
shannah — Fri Oct 26, 2012 9:05 am
Can you post some more information. E.g. the relevant relationships.ini definition and table definitions?
Also, what version of Xataface are you using?
simb — Fri Oct 26, 2012 9:43 am
Hi Shahnah,
xataface version is 1.3.2
The parent table is “tbl_application” and has “id” as a primary, auto increment field.
The child table is “trc” and has a filed “applicationId” which refrences the parent (tbl_application) id in FK relation ship.
The tables are linked in a one to many arrangement.
The relationship.ini includes:
[trc]
trc.applicationId = “$id”
action:label = Trc
action:order = 2
There are more than 17 active child tables in relationship.ini
The parent as well as child tables include thousand of entries and the application has more than 2000 users.
The issue occurs when multiple “add new related record” tabs are opened at the same time and we try to enter multiple records at the same time.
I have been able to handle the issue by changing the following else block:
else {
$app =& Dataface_Application::getInstance();
$qt =& Dataface_QueryTool::loadResult($app->_currentTable);
return $qt->loadCurrent();
}
– to:
else {
$app =& Dataface_Application::getInstance();
return $app->getRecord();
}
at around line 180 Dataface/ShortRelatedRecordForm.php
Thanks!
shannah — Fri Oct 26, 2012 9:47 am
Thanks for posting this. I’m not sure why this fix works, but I’ll look into it. I’ve add a bug report.
http://bugs.weblite.ca/view.php?id=1167
simb — Fri Oct 26, 2012 10:29 am
Thank you Steve - Always appreciate your support and hardwork!