有没有一种简单的方法可以在非 Kohana 应用程序中使用 Kohana DB 配置文件?通过阅读 Kohana_Config 类,我似乎无法弄清楚。
为什么?假设我有一个位于同一目录中的 cron 任务,我希望它使用相同的数据库配置。
这种愚蠢的尝试以失败告终……
function connection(){
$connection = file_get_contents('../application/config/database.php');
eval($connection);
}
以下是配置示例:
return array
(
'default' => array
(
'type' => 'mysql',
'connection' => array(
'hostname' => 'localhost',
'database' => 'some_db',
'username' => 'root',
'password' => 'root',
'persistent' => FALSE,
),
'table_prefix' => '',
'charset' => 'utf8',
'caching' => FALSE,
'profiling' => TRUE,
),