1 datatable and 4 mysql tables
1 datatable and 4 mysql tables
I have 1 datatables with data coming from 4 mysql tables. I managed to see all data in my datatable but i'm not able to update data in the joined tables. The main tables updates fine with references to data in the joined tables.
Is this even possible?
I use server side processing with leftjoins...
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Are you able to put up a test case for us to have a look at?
Sure!
PHP:
Javascript:
Thanks!
That does look like it should work okay as you have it. So the
Member
table is being updated, butUser
is not - is that correct?Are you receiving any errors from the PHP when you try to do an update?
You might also need to include
User.userKey
andMember.userKey
has hidden fields in the field list (both in the data read and the fields that Editor submits). But I would expect that to give an error in 1.3.2 if the join fields don't exist!Regards,
Allan
Thanks Allen!
The Member table was being updated but the User table not.
Including User.userKey and Member.userKey as hidden fields in both the Editor submit and in the data read fields did the trick. No errors but this is maybe because I did a suggested fix I found on teh Forum. In DataTables-1.10.2/extensions/Editor-1.3.2/php/Editor/Editor.php at line 1021 I have now:
Thanks for the help!
I have a couple tables with a similar issue. The editor buttons work fine when only the primary table is called in the fields (eg. "member.userkey") but it raises the "An error has occurred - Please contact the system administrator" error if I replace this field with a field from the joined table (eg. "user.name" ).
Interesting, in my case, the editor_update does work (on refreshing the page from the error message), but the error comes up anyhow.
I have included the unique keys from the joined tables, and checked all fields exist. I have been playing around with it a bit this evening without much luck I am afraid :(
Nigel,
Did you tried the fix I mentioned above?
Olan
Yes, thank you for that. I still am having my issue, but I will spend some more time picking through it.
Good luck with your project.
nige
Agreed. That is the danger of that fix. It is the right thing to do in some cases, but at other times the error that would have been generated is quite useful...
That's a JSON error. What has been returned rather than valid JSON?
Allan
Thanks Nigel.
Still truggeling with this tabel....
I added a extra tabel to it were i needed a join array to display my data. No errors and the table displayes almost the correct data.
When I edit a row it also messes up the Team table by deleting the name from it.
the tables i used for the join array looks like:
Member table:
memberKey
TeamLink table:
memberKey|teamKey
Team table:
teamKey|name
the code i have now is:
On line 84 of the js script i have now { data: "Member.teamKey"}, This should be { data: "Team.name"}, but because of the use of the join array where i also use the Team table this is not working anymore.
I hope i explained it correctly and the problem can be fixed. I don't see it anymore....
An update for anyone else who might be reading through this thread as we took the discussion offline to help resolve the issue.
Basically the problem was that
Team
was required as both aleftJoin
and an array join (due to the structure of the database schema). So the ability to alias a table name was useful here:becomes:
and the
Team.name
field updated to beT.name
. Everything else can stay as it was.Regards,
Allan