This way we are using the esc() method to sanitize the incoming user data. In it, after running the INSERT query on the database, we use the returned auto-assigned unique id with mysql_insert_id() and create a new todo object, which is then echoed out to the front end. // Select all the todos, ordered by position: $query = mysql_query("SELECT * FROM `tz_todo` ORDER BY `position` ASC"); $todos = array(); // Filling the $todos array with new To Do objects: while($row = mysql_fetch_assoc($query)) Later in the page, these objects are echoed out.Thanks to the __to String() method discussed above, all the markup is automatically generated, so we do not have to deal with any of that.If you're not too familiar with doing reverse Code First, go and find a good tutorial on Entity Framework Code First. Because I know the duplicate is the only order put in today, I do this: Guess what?Then go find one on Reverse Code First (which is doing Code First with an existing database). I just deleted both the duplicate AND the original!In SQL terms, their clause contains the original value of every field in the row, and if 0 rows are affected it knows something's gone wrong.The idea behind it is that you won't end up overwriting a change that your application didn't know has happened - it's basically a little safety measure thrown in by . If it's consistent, odds are it's happening within your own logic (EG: You're actually updating the data yourself in another method in-between the select and the update), but it could be simply a race condition between two applications.
All my searching shows up the same thing, that there is no primary key declared on the entity that I'm trying to update. Since I originally started mucking about with doing Entity Framework on old keyless databases, I've come to realize that the best thing you can do BY FAR is do it by reverse code-first.For a quick reference, check out these pages of PHP's documentation: OOP Basics, Static Methods, Exceptions, Magic Methods.Accessing static methods from the same class can easily be done with the self:: keyword.Edit: Unfortunately I am no longer at liberty to reproduce the problem I was having here, because I stepped away from this project and don't remember if I eventually found a solution, if another developer fixed it, or if I worked around it. That's a side-effect of a feature called optimistic concurrency.Not 100% sure how to turn it on/off in Entity Framework but basically what it's telling you is that between when you grabbed the data out of the database and when you saved your changes someone else has changed the data (Which meant when you went to save it 0 rows actually got updated).