panique / mini3

Just an extremely simple naked PHP application, useful for small projects and quick prototypes.
274 stars 100 forks source link

Fix for #15: Fixed bug for editSong throwing error when song_id doesn't exist #42

Closed mhco closed 6 years ago

mhco commented 6 years ago

For #15:

If a song doesn't exist in the database, the application will throw a PHP error. To fix this, I check for rowCount() of the getSong method, and, if it's zero (i.e. that song_id doesn't exist in the database), I return false. I then check the status of that in the SongsController editSong method, and display either the edit page, or the error page depending.

This can be changed by the user in a variety of ways.

Understanding this page probably doesn't matter much to users of this framework, a bug is a bug.

@panique this is a rudimentary solution, and certainly not a hyper elegant one. If there's a better solution for it, please feel free to change it. This uses the error solution from PR #41, to display the error page in-place, instead of redirecting to the error page; this can be changed easily, however.

panique commented 6 years ago

Thank you very much :) Good stuff!