如何在Kohana 3中配置SQLite?

前端之家收集整理的这篇文章主要介绍了如何在Kohana 3中配置SQLite?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我很难找到有关如何在Kohana 3.2中配置sqlite的任何信息.我主要需要知道:

>我应该将主机名,数据库,用户名和密码设置为(使用默认用户和无密码)?
>另外,如何设置sqlite数据库文件的路径?
>“类型”应该是什么?我试过“sqlite”,但是我找不到错误类’Database_sqlite’.

这是我目前的配置选项:

'exportedDatabase' => array
(
    'type'       => 'sqlite','connection' => array(
        /**
         * The following options are available for MysqL:
         *
         * string   hostname     server hostname,or socket
         * string   database     database name
         * string   username     database username
         * string   password     database password
         * boolean  persistent   use persistent connections?
         *
         * Ports and sockets may be appended to the hostname.
         */
        'hostname'   => $hostname,'database'   => $database,'username'   => $username,'password'   => $password,'persistent' => FALSE,),'table_prefix' => '','charset'      => 'utf8','caching'      => FALSE,'profiling'    => TRUE,

解决方法

您可以通过数据库模块使用PDO.正确的配置方式如下所示:

'exportedDatabase' => array(
    'type'       => 'pdo','connection' => array(
        'dsn'        => 'sqlite:/path/to/file.sqlite','charset'      => NULL,/* IMPORTANT- charset 'utf8' breaks sqlite(?) */ 
    'caching'      => FALSE,

在Kohana中使用PDO的一个缺点是,在ORM中,您必须在模型中手动指定所有字段(出于性能原因,您应该这样做),因为不同的数据库系统处理表字段的列表.

还有由banditron创建的real database模块.你必须记住,它不是数据库模块的替代品,因此Kohana的ORM不适用它.除此之外,它非常整洁,并且对sqlite以外的数据库系统提供了广泛的支持.

猜你在找的Sqlite相关文章