Php 数据库没有';t连接在科哈纳3
我正在尝试连接到我在Kohana 3中的数据库,但它没有连接 这是我试图从我的一个模块运行的查询:Php 数据库没有';t连接在科哈纳3,php,kohana-3,kohana-orm,Php,Kohana 3,Kohana Orm,我正在尝试连接到我在Kohana 3中的数据库,但它没有连接 这是我试图从我的一个模块运行的查询: $results = DB::select()->from('users')->where('verified', '=', 0)->execute(); 这是: ErrorException[注意]:未定义的属性:配置文件::$default MODPATH\database\classes\kohana\database.php[67] 如果($config==NULL)
$results = DB::select()->from('users')->where('verified', '=', 0)->execute();
这是:
ErrorException[注意]:未定义的属性:配置文件::$default
MODPATH\database\classes\kohana\database.php[67]
如果($config==NULL)
{
//加载此数据库的配置
//回声“;
//模具(打印(非序列化(Kohana::config('database'));
$config=Kohana::config('database')->$name;
}
如果(!isset($config['type']))
{
抛出新的Kohana_异常('未在:名称配置中定义数据库类型',
我在application/config/database.php中设置了以下配置
看起来Kohana根本找不到配置文件…通常这个文件位于/modules/database/config/database.php看起来Kohana根本找不到配置文件…通常这个文件位于/modules/database/config/database.php我认为不是这样的。Kohana网站和其他博客建议复制模块/database/config/database.php到application/config/database.php,这就是我所做的。顺便说一句,我也在modules/database/config文件夹中复制了配置,但运气不好。我不认为是这样。Kohana网站和其他博客建议将modules/database/config/database.php复制到application/config/database.php,这就是我所做的。顺便说一句,我知道还复制了modules/database/config文件夹中的配置,但没有成功。其他未连接的页面可以正常运行?showvar\u dump(Kohana::config('database'))
resulttothers未连接的页面可以正常运行?showvar\u dump(Kohana::config('database'))
result
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',
<?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,
),
);