Using editor with a composite primary key

Using editor with a composite primary key

MattDMattD Posts: 27Questions: 2Answers: 0
edited February 2014 in Editor
Hi,

I'm trying to use editor for a table with a composite primary key. I know I can change the pkey in the Editor.php, but I'm not sure how to change it so that it can hold a composite. Has anyone done this before?

Thanks!

Replies

  • allanallan Posts: 61,782Questions: 1Answers: 10,113 Site admin
    I'm afraid that the PHP libraries Editor comes with do not currently support multiple primary keys. It is something I'm going to look at for a future release, possibly 1.5, but fort he moment it would require a little bit of custom code on the server.

    Allan
  • MattDMattD Posts: 27Questions: 2Answers: 0
    Okay, no problem.
    Thanks!
  • rpmccormickrpmccormick Posts: 107Questions: 13Answers: 0

    Is this still the case? What bit of custom code is a workaround?

    For example, I have a "UserRelations" table allowing UserA to either block or favorite UserB. The table's primary-key is the combination of FromUser and ToUser. The table only has 3 fields: FromUser, ToUser, Status=None/Block/Fav.

    How can I get DataTables to show and edit this simple composite-primary-key table?

    If it cannot be done using the PHP that generator makes, then can you please point me to something helping me to understand how to accomplish the server-side stuff using my ASP.Net enviornment? I tried to learn but gave up and learned PHP instead.

  • allanallan Posts: 61,782Questions: 1Answers: 10,113 Site admin

    Yes this is still the case I'm afraid to say. There is currently no workaround when using the PHP libraries as the concept of a single primary key is fairly hard coded into them. I've been thinking about how to relax that recently, but haven't started developing any code for it yet as I'm working on C# libraries and what to get them to feature parity with PHP before adding new features to both.

    The Editor client / server communication protocol is documented in its manual might might be of some use. Basically you will need to handle a submit which contains data for the three fields plus one or two other components (the id of the row to be submitted for example, which in this case would have to be a concatenation of the two columns in question).

    Allan

This discussion has been closed.