Skip to content
Advertisement

Why is it stupid to create custom PDO query handlers? [closed]

According to this thread: https://codereview.stackexchange.com/questions/29362/very-simple-php-pdo-class people generally say it’s stupid to create custom PDO query handlers, which I find very hard to understand.

For instance, in my projects I prefer to have a class / function to do things I do all the time, quicker for me.

For instance, when you need to perform simple updates in a table, I have created this function, which I use all the time:

JavaScript

And the doQuery (which I also use when I want to query database):

JavaScript

Is there anything wrong with this? I find it extremely useful.

some code have been taken out of the scripts to simplify the code

Advertisement

Answer

I think what you’re doing is fine. The main argument in that thread is that you miss out on Prepared statements: I’ve been using SQL since about 1984 and DBMS’s have been good enough that using a Prepared statement makes no real difference since probably 1994. I haven’t used one for over 20 years and my systems do perform properly.

Still, everybody has their own opinion. I’ve done what you do many times and never had a problem with it. Nowadays I use ORM’s which means I don’t have to do that either.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement