To Do List Project: Part 6

Writing the ending time to each ToDoSlice item is more complex because we have to match to an existing record without benefit of having a unique ID to reference. Instead, we use a combination of the ToDoID index and the starting time for the slice, which we known from the sending form.

We start with the UpdateEndTime.php file. We get the information for all four columns of the ToDoSlices and then try to update the end time and note fields, which is where the trouble lies. Writing the ending time should be straightforward, since there should be no previous value for it in the record after it is created. Updating the Note field, however, will present a problem if its text has not changed. For some odd reason, MySQL’s update command won’t actually perform the update if a text value doesn’t change.

You can verify this by manually issuing the same statement as this code generates, which will cause the command-line interface to report 1 row matched but 0 rows changed. This operation won’t generate an error, it just won’t do anything at all, including update any other value in the record. For that reason the code jumps through a lot of hoops to update the end time and note fields separately, see if either operation generated an error, and report back the appropriate information. It’s probably possible that the end time will be properly updated while the note update fails (this would have to be something having to do with the MySQL host at a system level) so I should add some code to check for that condition. There are other options as well, one of which could be to only update the end time if a check of the note field reveals that its text has not changed.

This entry was posted in Software and tagged , , , , . Bookmark the permalink.

Leave a Reply