CodeIgniter Forums
CI3 - How to refer to PDO subdrivers from database.php config? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: CI3 - How to refer to PDO subdrivers from database.php config? (/showthread.php?tid=61579)



CI3 - How to refer to PDO subdrivers from database.php config? - elijahlofgren - 04-27-2015

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


RE: CI3 - How to refer to PDO subdrivers from database.php config? - elijahlofgren - 04-28-2015

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';