Kohana config database - enabling

1.1k views Asked by At

I can't make to Config_Database work.

I'm enabling new Config Source that way:

Kohana::$config->attach(new Config_Database, FALSE);

I'm loading that source after loading modules - in the bottom of bootstrap.php file.

I get this error when I'm trying to enable this Config Source

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 261900 bytes) in /var/www/moje/modules/database/classes/kohana/config/database/writer.php on line 124 

Line 124 in file (.../)database/writer.php doesnt exists - it has only 111 lines.

What's going wrong?

edit: Kohana 3.2

3

There are 3 answers

0
yretuta On

This sounds like a bug in 3.2 I have got it to work with 3.0 (haven't tried 3.1). Here's the thread in Kohana Forums:

http://forum.kohanaframework.org/discussion/9637/config_database-and-the-out-of-memory-error/p1

0
delphist On

It's going because Kohana trying to load database settings from database (and it's going to recursion)

You should initialize your database instance before attaching Config_Database reader

Try this (in bootstrap.php, after Kohana::modules()):

Database::instance();

Kohana::$config->attach(new Config_Database, FALSE);
0
Taai On

Or you can simply load database config right before adding the Config_Database

Kohana::$config->load('database');
Kohana::$config->attach(new Config_Database, FALSE);