catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.83k stars 1.15k forks source link

Feature request / recommendation: Exceptions and error handling #500

Closed lightpower92 closed 3 years ago

lightpower92 commented 7 years ago

I'm using Medoo for a while in my unique CMS system with success, but error handling, and error notification not the best in Medoo.

My opinion, that in other languages created (i.e.: Java/C#) database handlers' error reporting and handling strategies are good enough to use them in Medoo. These handlers have 2 basic difference campared with Medoo: 1) Throw exception in every situation when a SQL error happened --> it's a better way to catch exceptions and handle them, than searching for bad values in result... - Last week I had a duplicate key problem, and Medoo didn't reported it, so I had searched the problem for half an hour. It's strange, but last error was 0 too...

2) Every function sould reaturn a value that can be interpretable in every situation. For example insert function now returns the last inserted id - if there's an id column and it's auto incremented - but what if there's no id column with auto increment - in this situation Medoo always return 0 - because of this, in other db handlers, insert returns the affected rows count, so the programmer can check, that every information stored or not, and this information is always available, not depeding on column structure.

These are just recommendations, Medoo is a good project, and I love to use it in my CMS system, but these improvements would help to raise the quality of usage, and Medoo error handling would meet the standards.

blessedjasonmwanza commented 4 years ago

Medoo is a nice concept but, as a developer, facing errors and not knowing how to debug them is a dead end. I was to my final decision to adopting this tool for my big project, unfortunately this weakness gave me (and its still giving me ) a million questions. @Angelaon , @catfan is there a way to through an error either using error_get_last()["message"] when an execution fails? at-least we might be able to know how to fix certain problems arising from the software we're building for our users.

Please Help Devs out by putting this issue into consideration.

blessedjasonmwanza commented 4 years ago

@lightpower92 Look up on this for a start https://medoo.in/api/debug and https://medoo.in/api/log

I am personally hoping that your issue get looked into ASAP .