Fixing the checks that I should have fixed in the first place

On call with work this weekend so spent time some time doing a little housekeeping in the admin section. One of the things that I said before that I should fix and was annoying i fixed over the film/list/person add/edit. This was the editing of an entry and not changing an entry name but clicking off of it and it running a check on the link and realising there was already (the thing your editing) an entry with the same link.

To fix this I tried a couple of ways but I went with a slightly elegant all encompassing way. Currently it just checks against the link so I amended all the php db calls to take into consideration a passed through Id. If nothing was passed through it then just makes the id 0 that way when we search against the link and check the id it wont match anything that currently is in the DB. This is important for entries that are brand new and do not already have Id's.

I then edited the jQuery and Ajax. The first step was to add a check to see if there was an Id on the page (if yes this is an edit form if not its a new entry form), if there is one then we apply that value to a var if not we just apply the number 0 to the var. I then amended the ajax call to pass through the Id as well. All sounds quite easy and it was just time consuming to check and double check that it all worked as I expected it to. Some pages had different calls to JS and PHP files depending on if it was an edit or a new insert so had to edit both of these.

Building everything in this way means that it all works weather it is a edit or insert form and it doesn't care which one you are on it will still work in the exact same way. This way it keeps it simple and effective, which is my favorite way to code.

>>back<<