Use PDO instead of WPDB ???
Hi, I don’t do a lot of WordPress programming but I do a lot of web programming and I always use PDO for my database abstraction.
Biggest advantage, PDO lets the person running the app decide what database backend they want to use. For example, they may prefer PostgreSQL because they do stuff with GIS and need its spatial relations features.
And looking at the WordPress $WPDB documentation, so far I find several things that PDO does better and not a single thing that WPDB does better. The placeholder for prepared queries being a simple example, with PDO you can just use a ? and don’t have to worry about the data type or using %% where a % is a legitimate part of the query.
Since PDO is an object, you can still do things like
$pdo->tableprefix = 'foo_';
to make the table prefix available to plugins that need it.
Is there a reason I’m just not seeing as to why WordPress uses its own database abstraction that is tied to a single database over using something like PDO?
It seems to me that using PDO would not only open up the database backend options, but also would reduce the code that has to be maintained by the WordPress developers.
If there is something I’m just not getting, what is it?
- The topic ‘Use PDO instead of WPDB ???’ is closed to new replies.