Welcome Guest, Not a member yet? Register   Sign In
CI3 - How to refer to PDO subdrivers from database.php config?
#1

I'm trying to use the pdo_sqlsrv_driver.php that is new in CI3. However, I'm unable to figure out how to refer to the driver by name in database.config

If I try this I get "Invalid DB driver":

$db['local_windows_pdo']['dbdriver'] = 'pdo_sqlsrv';

I've looked for documentation but haven't been able to find how to refer to PDO sub drivers.

Thank you!
- Elijah
Reply
#2

I found that in __construct() in pdo_driver.php the subdriver is auto-determined. Thus, all that should be needed to use a PDO subdriver is setting dbdriver to 'pdo', the hostname portion is used to auto-select the appropriate subdriver.

Code:
$db['local_windows_pdo']['database'] = 'MY_DB';
$db['local_windows_pdo']['hostname'] = 'sqlsrv:server=(local)\MSSQLSERVER2012;Database=' . $db['local_windows_pdo']['database'];
$db['local_windows_pdo']['dbdriver'] = 'pdo';
Reply




Theme © iAndrew 2016 - Forum software by © MyBB