Using Sqlite3 with CakePHP(在 CakePHP 中使用 Sqlite3)
问题描述
我正在尝试使用 CakePHP 运行 Sqlite3.是的,我知道它没有得到官方支持,但是这篇文章在这里:如何将 CakePHP 连接到 SQLite 数据库?说有可能.我已经下载了新的驱动程序文件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
我的配置文件应该是什么样的.我应该引用驱动程序的完整文件名吗?像'驱动程序' => '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?
感谢您的帮助.我是蛋糕的新手,我很高兴能学到更多.
Thank you for your help. I'm new to cake and I'm excited about learning more.
推荐答案
驱动文件应该命名为 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'
这篇关于在 CakePHP 中使用 Sqlite3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 CakePHP 中使用 Sqlite3
基础教程推荐
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 无法解决整理冲突 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
