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.

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?

2 Answers 2


WordPress uses mysql_* functions.


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):


  • I checked the code at wp-db.php. On line, 1133, it's got the db_connect function and according to it, it's not even mysqli. I'm confused. line 1143 clearly has this; $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); and according to the PHP manual, ( php.net/manual/en/function.mysql-connect.php ), this is a mysql code, Not mysqli. Does WP really use mysql ? Feb 6, 2013 at 0:25
  • 6
    Wordpress uses outdated functions, since mysql_connect has officially been depreciated, wp will be moving hopefully to PDO soon (soon is 1-2 years). Ref: core.trac.wordpress.org/ticket/21663
    – Wyck
    Feb 6, 2013 at 0:44
  • @AverageJoe ... yes, like I said, WordPress uses mysql functions. Like Wyck, I am hoping for PDO, but I don't know which way it will go.
    – s_ha_dum
    Feb 6, 2013 at 1:01
  • Thank you for the trac link Wyck. s_ha_dum please include this link ( core.trac.wordpress.org/ticket/21663 ) in your answer and correct the grammar where you go "If has used those ever since I can remember," when you get a chance. Thank you Feb 6, 2013 at 1:52
  • A little bump. This was written one light year ago.. But today I believe we have mysqli_* in wordpress since some versions, right? Apr 7, 2014 at 12:29

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:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.