1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PDO_MySql driver not supported?

Discussion in 'XenForo Development Discussions' started by Shadab, Jan 21, 2011.

  1. Shadab

    Shadab Well-Known Member

    Looking at XenForo_Application::loadDb() and XenForo_Db::_execQuery(), I notice there's support for the pdo_mysql driver in XenForo. Or at least it was intended to provide support for pdo_mysql. But switching the adapter class via config.php doesn't really work seamlessly.
    $config['db']['adapter'] = 'pdo_mysql';

    (1) XenForo_Install_Model_Upgrade::getLatestUpgradeVersionId() now returns a string (correct data type for fetchOne, according to the published API) instead of an integer; which breaks any version checking.

    (2) Starting a nested transaction results in an sql error, sometimes. Happens just randomly. Couldn't find any pattern to it.

    (3) The forumlist page works, though. And it consistently loads ~15% faster with pdo, than with mysqli.

    Is it just me?
    And what's the status of PDO_MySql in XenForo: fully supported?
  2. Mike

    Mike XenForo Developer Staff Member

    No, it won't just be you. It's not supported at all. There was some testing with it, but things just run differently (for example, queries like EXPLAIN need to be run on the raw connection, IIRC). More significantly, since it's not using the binary protocol, it won't give us anything but strings, which is an issue.

    I haven't seen significantly speed ups from it, though I haven't done much analysis.
  3. Shadab

    Shadab Well-Known Member

    Uh oh.

    So would there be any conflict if I create a separate PDO based connection to the xenforo database, using the same login credentials? (After setting up xenforo's $db instance in the same script)
  4. Mike

    Mike XenForo Developer Staff Member

    No conflict - I just meant that silently swapping our $db object to PDO is going to be problematic, mostly because of the non-binary protocol differences as you discovered. They're really something that creep in, in totally unexpected places, so it's hard to not rely on it at this point. (On a side note, I've tried to avoid nulls in the past, because IIRC, you just got "", which wasn't easy to work with. The binary protocol actually gives you null. It's much nicer. :))
    Shadab likes this.
  5. Shadab

    Shadab Well-Known Member

    Thanks! I'll now have to just check its performance implications. And will probably do some more testing on why #2 was failing randomly, instead of outright failing every time. Even though savepoints were being created using the raw connection, like you said.

    Another library on its way to the 'Development Tutorials and Resources' forum. :)

Share This Page