lau*_*ent 4 sql sqlite configuration kohana kohana-3
我很难找到有关如何在Kohana 3.2中配置SQLite的任何信息.我主要需要知道:
我应该将主机名,数据库,用户名和密码设置为(默认用户和无密码)?
另外,如何设置SQLite数据库文件的路径?
"类型"应该是什么?我试过"sqlite",但是我收到了一个错误Class 'Database_Sqlite' not found.
这是我目前的配置选项:
'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,
),
Run Code Online (Sandbox Code Playgroud)
您可以通过数据库模块使用PDO.正确的配置方式如下所示:
'exportedDatabase' => array(
'type' => 'pdo',
'connection' => array(
'dsn' => 'sqlite:/path/to/file.sqlite',
'persistent' => FALSE,
),
'table_prefix' => '',
'charset' => NULL, /* IMPORTANT- charset 'utf8' breaks sqlite(?) */
'caching' => FALSE,
'profiling' => TRUE,
),
Run Code Online (Sandbox Code Playgroud)
在Kohana中使用PDO的一个缺点是,在ORM中,您必须在模型中手动指定所有字段(出于性能原因,您应该这样做),因为不同的数据库系统处理表字段的列表.
还有由banditron创建的真实数据库模块.你必须记住,它不是数据库模块的替代品,因此Kohana的ORM 不适用它.除此之外,它非常整洁,并且对SQLite以外的数据库系统提供了广泛的支持.
| 归档时间: |
|
| 查看次数: |
2667 次 |
| 最近记录: |