szlinz 发表于 2008-9-17 11:22:07

求助:如何在Kohana中配置SQLite3数据库

Kohana用的是最新的版本2.2,看到它的数据库驱动里有Pdosqlite.php,觉得它应该能支持Sqlite3,可不知道如何在配置文件里进行配置,谁知道的可否把代码写下来共享一下?我到官方网站上去查也没能查到。自己通过写PDO代码能够连接数据库,但用Kohana自带的驱动就不行。以下是我在database.php的配置文件代码:

$config['default'] = array
(
      'benchmark'   => TRUE,
      'persistent'    => FALSE,
      'connection'    => array
      (
                'type'   => 'pdosqlite',
                'user'   => '',
                'pass'   => '',
                'host'   => 'localhost',
                'port'   => FALSE,
                'socket'   => FALSE,
                'database' => 'pdosqlite://e:/myDoc/my Dropbox/data/mydb.db3'
      ),
      'character_set' => 'utf8',
      'table_prefix'=> '',
      'object'      => TRUE,
      'cache'         => FALSE,
      'escape'      => TRUE
);

但提示错误如下:
A database error occurred while performing the requested procedure. Please review the database error below for more information.
E:/myDoc/My Dropbox/www/system/libraries/drivers/Database/Pdosqlite.php :
There was an SQL error: SQLSTATE unable to open database file

[ 本帖最后由 szlinz 于 2008-9-17 12:45 编辑 ]

szlinz 发表于 2008-9-17 13:44:58

看来还得靠自己啊,问题得到解决,共享给大家,配置文件如下:


$config['default'] = array
(
      'benchmark'   => TRUE,
      'persistent'    => FALSE,
//      'connection'    => array
//      (
//                'type'   => 'mysql',
//                'user'   => '',
//                'pass'   => '',
//                'host'   => 'localhost',
//                'port'   => FALSE,
//                'socket'   => FALSE,
//                'database' => ''
//      ),
'connection'    => 'pdosqlite://'.APPPATH.'/data/mydb.db3',
      'character_set' => 'utf8',
      'table_prefix'=> '',
      'object'      => TRUE,
      'cache'         => FALSE,
      'escape'      => TRUE
);

注意:connection属性不要用数据形式,直接写连接参数就好了。

icyleaf 发表于 2008-9-18 00:18:07

数据库类是提供的数据库访问您的应用程序的的接口驱动。

目前支持下列的数据库驱动:
MySQL
MySQLi
PostgreSQL
PDOSqlite (SVN版本支持)
页: [1]
查看完整版本: 求助:如何在Kohana中配置SQLite3数据库