Can't Connect To SQLlite 3 Datbase Using SQLlite or PDO Drivers |
[eluser]Vheissu[/eluser]
I can't seem to get Codeigniter (latest version from Github) to work with my SQLlite3 database. I get the error: "file is encrypted or is not a database" system\database\drivers\sqlite\sqlite_driver.php on line number 78. Is this a known issue and are there any ways around this? When I create a SQLlite 2 database and try connecting to it I get further and get the following: Severity: Notice Message: Undefined property: Welcome::$db Filename: libraries/Session.php Line Number: 210 Connecting via PDO also throws errors about not being able to find a driver or something.
[eluser]toopay[/eluser]
If you use the latest state of develop branch, you could not use the native driver. Someone has been submitted a pull request regarding SQLite3 native driver, but it will take a while to get those pull merged. So for now, you could use SQLite2/3 with the PDO, by this prototype : Code: $db['testing_sqlite']['dsn'] = 'sqlite:/path/to/db.sqlite';
[eluser]Vheissu[/eluser]
Toopay thanks for replying so fast man. It appears that the above didn't work though. My code looks like this in the database.php file. My database file is in: application/db/ and called lucifer.db. Code: $db['sqlite']['dns'] = 'sqlite:/'.APPPATH.'/db/lucifer.db'; I appear to get a fatal error from the above aforementioned code: Code: Fatal error: Uncaught exception 'PDOException' with message 'invalid data source name' in C:\xampp\htdocs\lucifer\system\database\drivers\pdo\pdo_driver.php:113 Stack trace: #0 C:\xampp\htdocs\lucifer\system\database\drivers\pdo\pdo_driver.php(113): PDO->__construct(';dbname=', '', '', Array) #1 C:\xampp\htdocs\lucifer\system\database\DB_driver.php(127): CI_DB_pdo_driver->db_connect() #2 C:\xampp\htdocs\lucifer\system\database\DB.php(148): CI_DB_driver->initialize() #3 C:\xampp\htdocs\lucifer\application\third_party\MX\Loader.php(96): DB('', NULL) #4 C:\xampp\htdocs\lucifer\system\core\Loader.php(1172): MX_Loader->database() #5 C:\xampp\htdocs\lucifer\system\core\Loader.php(153): CI_Loader->_ci_autoloader() #6 C:\xampp\htdocs\lucifer\system\core\Controller.php(59): CI_Loader->initialize() #7 C:\xampp\htdocs\lucifer\application\third_party\MX\Base.php(55): CI_Controller->__construct() #8 C:\xampp\htdocs\lucifer\application\third_party\MX\Base.php(60): CI->__construct() #9 C:\xampp\htdocs\lucifer\application\third_party\MX\ in C:\xampp\htdocs\lucifer\system\database\drivers\pdo\pdo_driver.php on line 113
[eluser]toopay[/eluser]
From this build process i know that the recent PDO code works fine with SQLite3, so the problem may be one (or some) of this following reasons : - Your path is not pointed correctly to your SQLite database. To resolve, check using file_exists against the path. - Your file ownership (and also permission, if necessary), should be correctly allow PHP to work with it. To resolve, use (if you are in Ubuntu or other Unix OS) : Code: cd /path/to/your/db From above configuration you posted, at least this part : Code: $db['sqlite']['dns'] = 'sqlite:/'.APPPATH.'/db/lucifer.db'; Code: $db['sqlite']['dsn'] = 'sqlite:/'.APPPATH.'db/lucifer.db';
[eluser]Vheissu[/eluser]
Thanks for helping Toopay, I feel we're really getting closer here. Those above errors are gone using this line: Code: $db['sqlite']['dns'] = 'sqlite:'.APPPATH.'db/lucifer.db'; However I am now getting the error below: Code: Invalid DB Connection String for PDO All permissions are correct, I'm using XAMPP on a Windows machine, so no CHOWN'ing or anything required.
[eluser]toopay[/eluser]
You need to use 'dsn' instead 'dns'. Yes, i know anyone perhaps did not hear it since this is new param available on database.php, so anyone could easily misspeled.
[eluser]Vheissu[/eluser]
Ah, thanks mate that got rid of the above error. I'm probably going to drive you insane with this, but I'm not getting another error. "Fatal error: Call to a member function quote() on a non-object in C:\xampp\htdocs\lucifer\system\database\drivers\pdo\pdo_driver.php on line 475" I appreciate the help btw.
[eluser]toopay[/eluser]
That mean there is still an issue on your PDO connection, since quote is a PDO method. Are you autoload your database? If not, what method you use, which generate those error in your model? Also, you could do this simple test, to check whether your current database.php working or not, for PDO sqlite case : Code: // in some controller |
Welcome Guest, Not a member yet? Register Sign In |