Primary Key - no longer needed?
Primary Key - no longer needed?
sitesurfer
Posts: 34Questions: 9Answers: 0
in Editor
Quickie, just updated the libs after a year or so and realised that the editor (php) server side initialisation is no longer the same. Previously I have used a primary key to determine the correct field to edit - however on the new libs - there appears to be nowhere to set this pk - I'm wondering what magic you use to determine the correct field to use when editing a row?
This discussion has been closed.
Answers
Should add that I am going from 1.3 to 1.5.2
After hunting I found this.
Hi,
The primary key is required - Editor needs to be able to construct the update SQL with information about which row to edit (the primary key is currently the only option for this in the pre-built libraries).
The client / server data interchange used by Editor changed with the 1.5 release. The upgrade notes detail these changes, and also how to use the old scheme if you need to revert back to it (although you would loose the ability to edit multiple rows at the same time).
Allan
Hi Allan (and thanks for replying given the new addition (congrats!))
It would appear that in essence the setup is identical to previously, its the way its transmitted (as per docs you link) which has changed.
I think whats throwing me is that somehow I cant select the index of the POST array like I used to on a prior to edit/insert/delete action.
$_POST['data'][0]...blah should work but doesnt. (To get the row id back).
I'll figure it out :)
Gone back to previous legacy Ajax as per notes.
Will move forward with new pages/scripts using new code and cut the cloth accordingly.
Thanks!
aach..
So I reverted to old style ajax.
The editor (on a remove) is sending this:
action: remove
id[]: row_86
and I am getting an error from the php editor class:
<b>Notice</b>: Undefined index: data in <b>/jquery/DataTables
/Editor-1.5.2/php/Editor/Editor.php</b> on line <b>906</b><br />
Followed by an error as the data is not an array.
Odd?
I see - unfortunately the libraries that come with 1.5 will operate only with the new style of submitted data. They will not operate with the 1.4 style.
You could use the 1.4 server-side libraries, but the main benefit of 1.5 was its multi-row editing (which is why this change was required).
What is it that you want the id for? The server-side events introduced in 1.5 might be a good way to do this for you (depending on what you are doing).
Allan