开发者

Using Sqlite3 with CakePHP

I'm trying to run Sqlite3 with CakePHP. Yes, i know it's not officially supported, but this post here: How do I connect CakePHP to a SQLite database? says it's possible. I've downloaded the new driver file "dbo_sqlite3.7.php" and put it in "cake/libs/model/datasources/dbo". Now I'm having trouble getting connected to the db.

Things I'm confused on:

  1. Where should my database.sqlite file be kept

  2. What should my config file look like. Should I be referencing the full filename of the driver? Like 'driver' => 'dbo_sqlite3.7.php'? And can I us开发者_开发知识库e relative paths to the db file?

  3. Is there a difference in sqlite3 files and sqlite2 files by themselves, or is it just the way that you handle the files that makes the difference?

Thank you for your help. I'm new to cake and I'm excited about learning more.


The driver file should be named dbo_sqlite3.php. You can download the latest version from GitHub.

Your database config could look like this:

var $default = array(
    'driver' => 'sqlite3',
    'database' => 'database.sqlite'
);

CakePHP will look for the database file in app/webroot. You can use an absolute path or a path relative to the webroot directory. For example, if you'd rather store the database in the app directory (one level up from the webroot), you could write:

'database' => '../database.sqlite'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜