I have developed an open source PHP application and currently it uses both the MySQLi or MySQL extension for backwards compatibility. I'm wondering about switching it over to only be compatible with MySQLi since PHP now no longer supports the MySQL. Another reason I'd like to get away from supporting both MySQL and MySQLi is that I'm basically using MySQLi the same way I do as with the old MySQL extension. Can anyone explain to me if this is a good or bad idea?

  • If u use MySQLi, u gonna have bad time when doing integration testing. Unless u use a MySQL database in your tests too. Personally I prefer a SQLite database in development for rapid prototyping.
    – Songo
    Sep 2, 2013 at 22:25

3 Answers 3


If you are going to switch anyway, you should really consider going with PDO instead of MySQLi.

The main benefit, would be that your application would be able to work with any of the 11 other database backends supported by PDO, with minimal fuss. This might not be a priority for you, but since this is an open source application there's little reason to not try and make it as flexible as possible. Also, you'd be able to use named parameters in your prepared statements (MySQLi supports prepared statements, but not named parameters).

In any case, moving away from the mysql_* functions is a very good idea. These days, it's just a relic of the (dark) past, and unless backwards compatibility is an inescapable requirement there's absolutely no reason to use it.


The preferred method is to use only mysqli. As you said, the older MySQL extension is no longer supported. Both can connect to most versions of MySQL server, so there's no reason at all to use the old extension.

  • The only thing that should give you pause is if you have active users who do not have mysqli available in their php installations. If they exist, you'll be doing a favor by forcing them to upgrade, but it might be nice to warn them first.
    – grossvogel
    Sep 2, 2013 at 20:31

In terms of performance, mysqli is better, if your intended users are solely mysql based, then use mysqli else you can try PDO which will give you the flexibility of connecting to other databases with minimal changes.

I think PDO is slightly slower due to that fact that its more generic compared to mysqli or oci, but that is nothing to worry about.

You can create 2 scripts, one with PDO, the other with Mysqli and you apache ab to benchmark. With my test Mysqli was slightly faster in terms of request processed as compared to PDO but I must admit was negligible.

  • is this only your opinion or you can back it up somehow?
    – gnat
    Apr 1, 2014 at 9:14
  • Thanks, I actually created two scripts using mysql and mysqli respectively, in mysqli, I was able to use prepared statements, more of a stored procedure, I then used apache abs to access the two scripts and realized that the mysqli was a little faster than mysql, moreover a lot of site advocates the use of mysqli over mysql.It's been a while but will share some script soon. Thanks once again Nov 3, 2014 at 22:25

Your Answer

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

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