数据库无法连接Kohana 3

时间:2011-03-15 11:45:11

标签: php kohana-3 kohana-orm

我正在尝试连接到Kohana 3中的数据库,但它没有连接。

这是我试图从我的一个模块运行的查询:

$results = DB::select()->from('users')->where('verified', '=', 0)->execute();

这是the dump of the error

ErrorException [ Notice ]: Undefined property: Config_File::$default
MODPATH\database\classes\kohana\database.php [67]
if($config === NULL)
{
    // Load the configuration for this database
    // echo "<pre>";
    //die(print_r(unserialize(Kohana::config('database'))));
    $config = Kohana::config('database')->$name;
}

if(!isset($config['type']))
{
   throw new Kohana_Exception('Database type not defined in :name configuration',

我在application / config / database.php中有以下配置设置

<?php defined('SYSPATH') or die('No direct access allowed.');
return array
(
    'default' => array
    (
        'type'       => 'mysql',
        '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'   => 'localhost',
            'database'   => 'test',
            'username'   => 'root',
            'password'   => FALSE,
            'persistent' => FALSE,
        ),
        'table_prefix' => '',
        'charset'      => 'utf8',
        'caching'      => FALSE,
        'profiling'    => TRUE,
    ),
    'alternate' => array(
        'type'       => 'pdo',
        'connection' => array(
            /**
             * The following options are available for PDO:
             *
             * string   dsn         Data Source Name
             * string   username    database username
             * string   password    database password
             * boolean  persistent  use persistent connections?
             */
            'dsn'        => 'mysql:host=localhost;dbname=test',
            'username'   => 'root',
            'password'   => FALSE,
            'persistent' => FALSE,
        ),
        /**
         * The following extra options are available for PDO:
         *
         * string   identifier  set the escaping identifier
         */
        'table_prefix' => '',
        'charset'      => 'utf8',
        'caching'      => FALSE,
        'profiling'    => TRUE,
    ),
);

我在Windows XP上使用XAMPP 1.7.4和PHP 5.3.3

有谁知道我做错了什么?

1 个答案:

答案 0 :(得分:1)

好像Kohana根本找不到配置文件...通常这个文件位于/modules/database/config/database.php