Uploaded image for project: 'COmanage'
  1. COmanage
  2. CO-1433

DatabaseShell fails with PHP 7 and MySQL

    XMLWordPrintable

Details

    Description

      The mysql driver was removed from PHP 7.

      So this code in DatabaseShell.php fails when the CakePHP configuration has 'datasource' => 'Database/Mysql' and PHP_MAJOR_VERSION >= 7:

      $db_driver = explode("/", $db->config['datasource'], 2);

      if($db_driver[0] != 'Database')

      { throw new RuntimeException("Unsupported db_method: " . $db_driver[0]); }

      $dbc = ADONewConnection($db_driver[1]);

      The ADOdb preferred driver for PHP 7 is mysqli. See

      http://adodb.org/dokuwiki/doku.php?id=v5:database:mysql

      A tested solution that works is

      $db_driver = explode("/", $db->config['datasource'], 2);

      if($db_driver[0] != 'Database')

      { throw new RuntimeException("Unsupported db_method: " . $db_driver[0]); }

      $db_driverName = $db_driver[1];
      if(preg_match("/mysql/i", $db_driverName) && PHP_MAJOR_VERSION >= 7)

      { $db_driverName = 'mysqli'; }

      $dbc = ADONewConnection($db_driverName);

      Attachments

        Activity

          People

            scott.koranda.3@at.internet2.edu Scott Koranda SCG (Inactive)
            scott.koranda.3@at.internet2.edu Scott Koranda SCG (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: