EllisLab/CodeIgniter — Issue #726: PDO sqlite generates incorrect DSN
Author: DaSpawn
Created: 2011-11-30 18:27:06+00:00
State: open

Attempting to utilize sqlite3 on devel machine, the DSN is constructed improperly:

CodeIgniter_2.1.0
settings in
$db['default']['hostname'] = 'sqlite:db/test1.sqlite3';
$db['default']['username'] = '';
$db['default']['password'] = '';
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'pdo';

constructs improper DSN of 'sqlite:db/test1.sqlite3;dbname='

caused by:
system/database/drivers/pdo/pdo_driver.php:81
$this->hostname .= ";dbname=".$this->database;

correcting to check for empty database name:
if (!empty($this->database)){
$this->hostname .= ";dbname=".$this->database;
}

fixes problems using pdo_sqlite (have not tested with other database types yet, but sqlite db works fine now and should not cause any issues with other db types)