Problem connecting to sqlite database |
[eluser]grumble[/eluser]
Hi good CI people, I hate for my first post to be a cry for help, rather than something more positive, but needs must... I've just started using CI and am trying to connect to my SQLite database. Here is my setup. database.php: Code: ... ../application/controllers/test_controller.php: Code: <?php I can see "test 1" on my page, but not "test 2". I don't get any error messages or anything. "test.db" is readable by everybody. Any suggestions?
[eluser]Jondolar[/eluser]
You might want to turn on error reporting if it is disabled: Also, try logging an error to see if the load->database is even returning. http://ellislab.com/codeigniter/user-gui...rrors.html
[eluser]grumble[/eluser]
Thanks for your suggestions Jondolar. I checked my main "index.php" file and I still have the default: Code: error_reporting(E_ALL); Code: $this->load->database();
[eluser]grumble[/eluser]
He he he... Progress! First, I used Code: apt-get install php5-sqlite Code: A Database Error Occurred unable to open database: /var/www/CodeIgniter_1.7.1/< my path>
[eluser]grumble[/eluser]
OK, so rather than using "~" in my path, I started with "/home/..." CI got the picture and didn't prefix my path. Unfortunately, I still got an error: Code: A Database Error Occurred http://ellislab.com/forums/viewthread/88885/ and the wiki http://codeigniter.com/wiki/PDO_SQLite3/ suggests an alternative approach, using PDO as a database driver. In this approach, database.php would have: Code: $db['default']['database'] = "sqlite:/<path to database>/test.db3";
[eluser]grumble[/eluser]
OK! After following the instructions at http://codeigniter.com/wiki/PDO_SQLite3/ including all the extra files, and making the suggested changes to database.php, I finally got everything working! I guess PDOs are a nice generic way of working with databases. I really don't like the look of some of the hacks in "pdo_driver.php" though. I also think it sucks that it is so difficult to get CI working with sqlite3! Surely sqlite is a more appropriate "default" database!? |
Welcome Guest, Not a member yet? Register Sign In |