问题描述
我试图用CakePHP运行Sqlite3。是的,我知道它不是官方支持,但这篇文章:说这是可能的。我已经下载新的驱动程序文件dbo_sqlite3.7.php,并把它放在cake / libs / model / datasources / dbo。现在我无法连接到数据库。
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.
我困惑的事情:
-
我的database.sqlite文件应该放在哪里
Where should my database.sqlite file be kept
我的配置文件应该是什么样子。我应该引用驱动程序的完整文件名吗?喜欢'driver'=>'dbo_sqlite3.7.php'?我可以使用db文件的相对路径吗?
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 use relative paths to the db file?
sqlite3文件和sqlite2文件本身有区别,处理导致差异的文件?
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?
感谢您的帮助。
推荐答案
驱动程序文件应命名为 dbo_sqlite3.php
。您可以从GitHub下载 。
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将在app / webroot中查找数据库文件。您可以使用绝对路径或相对于webroot目录的路径。例如,如果您想将数据库存储在应用程序目录(从webroot向上一级),您可以这样写:
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'
这篇关于将Sqlite3与CakePHP结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!