WordPress mysqli and PDO

Does WordPress code base use mysqli or PDO?

I know PDO is superior to mysqli but mysqli is not bad neither. Plus from one of the features of what makes PDO is superior to mysqli ( that is being database agnostic ) does not mean much to WordPress as WordPress will always use mysql server. But binding params with data types is something PDO supports but mysqli does not and it’s a good thing.

Read More

My guts tell me that WordPress does use mysqli but I could not see it in the code base yet.

My second question is if WordPress is using mysqli, is it because of speed concerns or is it because back in the earlier days (when WP was being developed), PDO wasn’t just there yet?

Related posts

Leave a Reply

2 comments

  1. WordPress uses mysql_* functions.

    http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/wp-db.php

    It has used those ever since I can remember, which probably answers your last question. It is what I would consider legacy code. I suspect it will be updated sometime soon (those functions were only deprecated as of PHP 5.5, I believe). I don’t know which route development will go.

    Link to a ticket in Trac, courtesy of Wyck (from a comment below):

    http://core.trac.wordpress.org/ticket/21663

  2. An update for WordPress 3.9+ – with PHP 5.5 deprecating the mysql_* functions WordPress has begun using the mysqli if it is available on the server. Your future plugins and code should take this into consideration and stop using mysql_*. Right now, in 3.9, wordpress checks for the availability of mysqli and uses it if available. If not it uses mysql_* but that check will be removed at the earliest possible convenience. Down the road it seems they will be using PDO but that is a larger project.

    Here is an FAQ and announcement on it:

    http://make.wordpress.org/core/2014/04/07/mysql-in-wordpress-3-9/