This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Nevermore
Nevermore

Hi everyone.. i'm new to PHP Framework and laravel is the first framework i learned so does OctoberCMS.. I'm trying to install OctoberCMS via installer and using SQL Server Driver , but then comes Error [Connection failed: could not find driver]

  • I am using Xampp 5.6.3 [Php 5.6.3]
  • in Phpinfo() -> pdo_sqlsrv support : enabled
  • in Phpinfo() -> sqlsrv support: enabled
  • i have both [php_pdo_sqlsrv_56_ts] and [php_sqlsrv_56_ts] in ../php/ext/
  • i have SQL Server Native Client 11.0 in ODBC Drivers

anyone have same issue with me?

thanks in advance

Ariansyah

Last updated

asbig
asbig

I looks like they're expecting PDO_DBLIB according to the code in install_files\php\installer.php line 151:

case 'sqlsrv':
    $availableDrivers = PDO::getAvailableDrivers();
    $_port = $port ? ','.$port : '';
    if (in_array('dblib', $availableDrivers))
        $dsn = 'dblib:host='.$host.$_port.';dbname='.$name;
    else {
        $_name = ($name != '') ? ';Database='.$name : '';
        $dsn = 'dblib:host='.$host.$_port.$_name;
    }

But as the manual says, "This extension is not available anymore on Windows with PHP 5.3 or later. "!

Last updated

Nevermore
Nevermore

Thank you for you response,Asbig.. As mentioned above , i have php_sqlsrv_56_ts.dll and php_pdo_sqlsrv_56_ts.dll which is the result of installing drivers from MSDN. i chose version 3.2 (support for PHP 5.4 and later).

And still couldn't install OctoberCMS with SQL Server :)

asbig
asbig

Hi Nevermore,

It doesn't look like those drivers are supported yet.

I made a quick test by adding the following lines to the onValidateDatabase() function (line 108) in install_files\php\installer.php to see if it would install using the drivers you have:

protected function onValidateDatabase()
{
    .
    .
    .
        case 'sqlsrv':
            $availableDrivers = PDO::getAvailableDrivers();
            $_port = $port ? ','.$port : '';                
            if (in_array('dblib', $availableDrivers)) {
                $dsn = 'dblib:host='.$host.$_port.';dbname='.$name;
            }

// asbig 20150423 Check for sqlsrv
            elseif (in_array('sqlsrv', $availableDrivers))
                $dsn = 'sqlsrv:Server='.$host.';Database='.$name;             
// asbig 20150423 End check for sqlsrv

            else {
                $_name = ($name != '') ? ';Database='.$name : '';
                $dsn = 'dblib:host='.$host.$_port.$_name;
            }
        break;
    }
    try {
        $db = new PDO($dsn, $user, $pass, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
    }
    catch (PDOException $ex) {
        throw new Exception('Connection failed: ' . $ex->getMessage());
    }

    /*
     * Check the database is empty
     */
    if ($type == 'sqlite')
        $fetch = $db->query("select name from sqlite_master where type='table'", PDO::FETCH_NUM);
    elseif ($type == 'pgsql')
        $fetch = $db->query("select table_name from information_schema.tables where table_schema = 'public'", PDO::FETCH_NUM);

// asbig 20150423 Check for sqlsrv
    elseif ($type == 'sqlsrv' && in_array('sqlsrv', $availableDrivers))
        $fetch = $db->query("select table_name from information_schema.tables where table_schema = 'public'", PDO::FETCH_NUM);
// asbig 20150423 End check for sqlsrv

    else
        $fetch = $db->query('show tables', PDO::FETCH_NUM);

    $tables = 0;
    while ($result = $fetch->fetch()) $tables++;

    if ($tables > 0)
        throw new Exception(sprintf('Database "%s" is not empty. Please empty the database or specify another database.', $name));
}

Which gets me as far as downloading the application files but fails at the "Create admin account" step with:

SQLSTATE[08001]: [Microsoft][SQL Server Native Client 11.0]TCP Provider: No connection could be made because the target machine actively refused it.

Something went wrong during the installation. Please check the log file or see the documentation for more information.

I'm pretty sure that SQL SERVER isn't supported as yet because of the PHP version limitation for PDO_DBLIB.

Is it absolutely essential that you use SQL SERVER or can you manage with MYSQL?

asbig
asbig

Okay, I take that all back.

It looks like you can use your drivers if you create an installation using the console interface instructions.

I had a problem with "invalid connection string" when trying to run the step: php artisan october:up

which gave the exception:

[PDOException] SQLSTATE[08001]: [Microsoft][SQL Server Native Client 11.0]SQL Server Network Interfaces: Connection string is not valid [87].

I traced it to C:\Apache24\htdocs\myoctober\vendor\laravel\framework\src\Illuminate\Database\Connectors\SqlServerConnecor.php.

The buildHostString method was adding a comma (,) after the host name so I took that out.

BUT then I updated the build through settings in the backend web page and it crashed again!

Having another go...

Last updated

asbig
asbig

Here's where I took out the offending comma:

protected function getSqlSrvDsn(array $config)
{
    $arguments = array(
    // took out the seperator parameter below
        'Server' => $this->buildHostString($config, '')
    );

    if (isset($config['database'])) {
        $arguments['Database'] = $config['database'];
    }

    if (isset($config['appname'])) {
        $arguments['APP'] = $config['appname'];
    }

    return $this->buildConnectString('sqlsrv', $arguments);
}

Updating to the current build 244, completely changes SqlServerConnector.php:

protected function getSqlSrvDsn(array $config)
{
    $port = isset($config['port']) ? ','.$config['port'] : '';

    $dbName = $config['database'] != '' ? ";Database={$config['database']}" : '';

    return "sqlsrv:Server={$config['host']}{$port}{$dbName}";
}

When I try to update to the latest build I get (at the finishing update step(?)):

Update failed

"Maximum execution time of 30 seconds exceeded" on line 47 of C:\Apache24\htdocs\october_test\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php

The "Try Again" button doesn't seem to do anything.

Last updated

asbig
asbig

The time out was caused by an uncaught PDO exception of invalid connection string.

That comma's back!

I took out the comma in the updated SqlServerConnector.php:

protected function getSqlSrvDsn(array $config)
{
    // Took out the comma from true condition in the ternary operator below
    $port = isset($config['port']) ? ''.$config['port'] : '';

    $dbName = $config['database'] != '' ? ";Database={$config['database']}" : '';

    return "sqlsrv:Server={$config['host']}{$port}{$dbName}";
}

Looks okay now.

Don't ask me about plugins!

*Edit

It turns out that I had to take the comma out because even though I had no port configured in config/database.php $config['port'] was still being set which gave the invalid connection string.

I went back to the original problem using the install-master method and found that this connection issue was also the cause of the ""Create admin account" step.

When I replaced the port setting in config/database.php from 1433 to '' and took out the comma in SqlServerConnector.php, the admin account was created after clicking "Try Again".

I was using SQLEXPRESS with tcp/ip disabled so you may not even get this issue if you have the port configured.

Last updated

lmmacias198619385
lmmacias198619385

Hello friend, you were able to install octobercms with sql server, I can not, it reaches the window to create administrator account and will not let me continue.

asbig
asbig

lmmacias198619385 said:

Hello friend, you were able to install octobercms with sql server, I can not, it reaches the window to create administrator account and will not let me continue.

Hi,

Wow! It's been a while.

To answer your question, yes I did manage to use SQLEXPRESS at the time by hacking away using the points I mentioned.

There's been quite a few revisions to OctoberCMS since though. Hmm... maybe I'll give it another go now you brought it up.

Best, Lee.

chris10207
chris10207

having the same issue trying to install OC on Azure with SQL Server 2018

I setup the port to 1433.

Connection failed: SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]SQL Server Network Interfaces: Connection string is not valid [87].

Last updated

1-10 of 10

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.