Connecting to MS SQL database as secondary database connection Failing

Permalink
I started by looking at this code http://documentation.concrete5.org/developers/database-management/c...

instead of 'driver' => 'c5_pdo_mysql' i used 'driver' => 'c5_pdo_sqlsrv',

but then ran into an error because there was not class for it, so I created
/concrete/src/database/driver/PDPSqlsrvConcrete5/Driver.php

Now i get error

Class '\Concrete\Core\Database\Driver\PDOSqlsrv\Driver' not found

Though the file is there.

Maybe I just went in the wrong direction. Any assisntance is appreciated.

wavemedia
View Replies:
exchangecore replied on at Permalink Reply
exchangecore
Take a look athttp://stackoverflow.com/questions/30593616/concrete-5-7-switch-dat...

By default ONLY the c5_pdo_mysql driver is registered, you need to register the appropriate driver. So you database.php file in your config might end up looking something closer to this:

<?php
return array(
    'default-connection' => 'concrete',
    'drivers' => array(
        'pdo_sqlsrv' => 'Doctrine\DBAL\Driver\SQLSrv\Driver'
    ),
    'connections' => array(
        'concrete' => array(
            'driver' => 'c5_pdo_mysql',
            'server' => 'localhost',
            'database' => 'c5',
            'username' => 'uuuuuuuuu',
            'password' => 'pppppppppp',
            'charset' => 'utf8',
        ),


Notice how I had to register my driver as 'pdo_sqlsrv', and map it to an actual driver implementation class. You'll need to find the appropriate driver for your needs. Best of luck!
wavemedia replied on at Permalink Reply
wavemedia
SO instead of the SQLsrv driver, I have PDOSqlsrv on my system, so i changed your code for driver array to

'pdo_sqlsrv' => 'Doctrine\DBAL\Driver\PDOSqlsrv\Driver'

only thing is now i get an error

Call to undefined method Doctrine\DBAL\Driver\PDOStatement::fetchRow()

Im going to try to get SQLSrv installed on on server, but not sure if that will do it.
exchangecore replied on at Permalink Reply
exchangecore
Nope fetchRow is a deprecated concrete5 function. It's new form is just ->fetch() which should be common across the other doctrine drivers I believe.

For a list of these check out Concrete\Core\Database\Driver\PDOStatement they are just there for backwards compatibility but you shouldn't be using them in new development.