Nette 2.1 rc4 a database-options-lazy=yes
- David Matějka
- Moderator | 6445
„vadilo“ znamena co? vypsalo to nejakou chybu?
lazy option udela, ze se pri inicializaci Connection hned nepripoji, ale az pri prvnim pozadavku na databazi. tipoval bych, ze na te strance neprobiha zadny dotaz a nedoslo tedy k pripojeni, coz debuggeru vadilo..
- n.u.r.v.
- Člen | 485
matej21 napsal(a):
„vadilo“ znamena co? vypsalo to nejakou chybu?
lazy option udela, ze se pri inicializaci Connection hned nepripoji, ale az pri prvnim pozadavku na databazi. tipoval bych, ze na te strance neprobiha zadny dotaz a nedoslo tedy k pripojeni, coz debuggeru vadilo..
Laděnka píše toto:
Nette\InvalidStateException
Unknown option nette.database.lazy.
a označen tento řádek: 26: $container = $configurator->createContainer();
Editoval n.u.r.v. (20. 12. 2013 22:31)
- n.u.r.v.
- Člen | 485
enumag napsal(a):
Ukaž jak to máš v configu pls.
Ahoj,
config.neon:
#
# SECURITY WARNING: it is CRITICAL that this file & directory are NOT accessible directly via a web browser!
#
# If you don't protect this directory from direct web access, anybody will be able to see your passwords.
# https://nette.org/en/security-warning
#
parameters:
smtp_server: ""
mail_template_t: 4
mail_template_p: 5
mail_template_s: 6
mail_template_re: 7
...
...
TokenDurationValidity: 20
SupportTextMaxLength: -1
php:
date.timezone: Europe/Prague
# zlib.output_compression: yes
nette:
application:
errorPresenter: StaticPage:Error
mapping:
*: App\Modules\*\*Presenter
session:
expiration: 14 days
services:
authenticator: Authenticator
- Model\EmailRepository(%smtp_server%)
- Model\SupportRepository
- Model\UserRepository(Nette\Database\Context(@nette.database.project_data), Nette\Database\Context(@nette.database.project_log))
- Model\MessageRepository
- Model\SchoolRepository
- Model\ImportRepository(Nette\Database\Context(@nette.database.project_data), Nette\Database\Context(@nette.database.jiny_project_users))
- Model\UniversalRepository(%TokenDurationValidity%)
- App\RouterFactory
router: @App\RouterFactory::createRouter
a config.local.neon (DB):
nette:
database:
project_data:
dsn: 'mysql:host=ip_adresa1;dbname=project_data'
user: nejaky_user
password: nejake_heslo
project_log:
dsn: 'mysql:host=ip_adresa1;dbname=project_log'
user: nejaky_user
password: nejake_heslo
jiny_project_users:
dsn: 'mysql:host=ip_adresa2;dbname=jiny_project_users'
user: nejaky_user
password: nejake_heslo
options:
lazy: yes
container:
debugger: true
bootstrap.php:
<?php
// Load Nette Framework or autoloader generated by Composer
require __DIR__ . '/../vendor/autoload.php';
define("LIBS_DIR", __DIR__ . "/../vendor/others/");
define("www_DIR", __DIR__ . "/../www/");
$configurator = new Nette\Configurator;
// Enable Nette Debugger for error visualisation & logging
//$configurator->setDebugMode(TRUE);
$configurator->enableDebugger(__DIR__ . '/../log');
// Specify folder for cache
$configurator->setTempDirectory(__DIR__ . '/../temp');
// Enable RobotLoader - this will load all classes automatically
$configurator->createRobotLoader()
->addDirectory(__DIR__)
->addDirectory(__DIR__ . '/../vendor/others')
->register();
// Create Dependency Injection container from config.neon file
$configurator->addConfig(__DIR__ . '/config/config.neon');
$configurator->addConfig(__DIR__ . '/config/config.local.neon');
$container = $configurator->createContainer();
\Nette\Diagnostics\Debugger::$bar->addPanel(new SessionPanel($container->session));
return $container;
Toto v nette 2.1 dev fungovalo, ale po aktualizaci na 2.1 RC4 to funguje pouze když smažu celé options,lazy,yes (zkoušel jsem místo yes dávat true a taky chyba)
Editoval n.u.r.v. (22. 12. 2013 10:52)
- enumag
- Člen | 2118
A takhle?
nette:
database:
project_data:
dsn: 'mysql:host=ip_adresa1;dbname=project_data'
user: nejaky_user
password: nejake_heslo
options:
lazy: yes
project_log:
dsn: 'mysql:host=ip_adresa1;dbname=project_log'
user: nejaky_user
password: nejake_heslo
options:
lazy: yes
jiny_project_users:
dsn: 'mysql:host=ip_adresa2;dbname=jiny_project_users'
user: nejaky_user
password: nejake_heslo
options:
lazy: yes
container:
debugger: true
- n.u.r.v.
- Člen | 485
enumag napsal(a):
A takhle?
nette: database: project_data: dsn: 'mysql:host=ip_adresa1;dbname=project_data' user: nejaky_user password: nejake_heslo options: lazy: yes project_log: dsn: 'mysql:host=ip_adresa1;dbname=project_log' user: nejaky_user password: nejake_heslo options: lazy: yes jiny_project_users: dsn: 'mysql:host=ip_adresa2;dbname=jiny_project_users' user: nejaky_user password: nejake_heslo options: lazy: yes container: debugger: true
Jů, funguje…díky… Taková blbost :-) …