您的位置:首页 > 数据库

Kohana的数据库配置

2013-11-13 10:16 302 查看
1、在application/bootstrap.php
文件里找到Kohana::modules并打开database开关

Kohana::modules(array(
//'auth'       => MODPATH.'auth',       // Basic authentication
// 'cache'      => MODPATH.'cache',      // Caching with multiple backends
// 'codebench'  => MODPATH.'codebench',  // Benchmarking tool
'database'   => MODPATH.'database',   // Database access
// 'image'      => MODPATH.'image',      // Image manipulation
// 'minion'     => MODPATH.'minion',     // CLI Tasks
// 'orm'        => MODPATH.'orm',        // Object Relationship Mapping
// 'unittest'   => MODPATH.'unittest',   // Unit testing
// 'userguide'  => MODPATH.'userguide',  // User guide and API documentation
));


2、将modules/database/config/里的database.php复制到application/config/目录下

<?php defined('SYSPATH') OR die('No direct access allowed.');

return array
(
'default' => array
(
'type'       => 'MySQL',
'connection' => array(
'hostname'   => 'localhost',
'database'   => 'kohana',
'username'   => 'root',
'password'   => 123456,
'persistent' => FALSE,
),
'table_prefix' => '',
'charset'      => 'utf8',
'caching'      => FALSE,
),
'alternate' => array(
'type'       => 'PDO',
'connection' => array(
'dsn'        => 'mysql:host=localhost;dbname=kohana',
'username'   => 'root',
'password'   => 'r00tdb',
'persistent' => FALSE,
),
'table_prefix' => '',
'charset'      => 'utf8',
'caching'      => FALSE,
),
);
其中default为必须定义的

MySQL 数据库能接受下面的连接配置选项

字符串的主机名 hostname *端口和套接字可以添加到主机名

例如:localhost:3306

字符串的套接字 socket

字符串的用户名 username

字符串的密码 password

布尔值的持久链接 persistent

字符串的数据库名 database

PDO 数据库能接受下列这些连接配置选项

字符串的数据源 dsn

字符串的用户名 username

字符串的密码 password

布尔值的持久链接 persistent

字符串的标识符 identifier
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: