I decided to start a new thread for the other thread was getting quite lengthy and thought it would be best to start a new one. Anyways, when I first started learning PHP I went to using books for I thought they would be “better” than online tutorials. I was sure wrong, for the author used try…catch to report errors when using PDO. I just found out that isn’t the best policy -
[i]However, in general, no dedicated treatment for PDO exceptions is ever needed. In short, to have PDO errors properly reported:
Set PDO in exception mode.
Do not use try…catch to report errors.
Configure PHP for proper error reporting
on a live site set display_errors=off and log_errors=on
on a development site, you may want to set display_errors=on
of course, error_reporting has to be set to E_ALL in both cases
As a result, you will be always notified of all database errors without a single line of extra code! [/i]
The link to that good article is https://phpdelusions.net/pdo (I think it might had been posted here before, but at the time I never paid attention to it.)
Programming can be bad enough, but having people who are supposedly “experts” showing people who are new to PHP (or any programming language) wrong techniques or procedures can be frustrating to say the least. I used to say to people learning PHP to use a book for online tutorials can be horrible; however, I think I need to revise this to “be careful in selecting a tutorial” by doing some background checking on the tutorial itself. However, this can be potentially frustrating for a new person learning to code. :’(
HTH someone - John