Argument 1 passed to Nette\Database\Context::__construct() must be an instance of Nette\Database\Connection

Notice: This thread is very old.

6 years ago

Zdenal
Member | 21
+
0
-

Hello, I have problem with version 2.1. I can't solve this problem:

Argument 1 passed to Nette\Database\Context::__construct() must be an instance of Nette\Database\Connection, string given, called in C:\VertrigoServ\www\data\cms\temp\cache\_Nette.Configurator\_-65790452d9726fa3652d2ec32321717f.php on line 177 and defined

Can someone help me?

Thank you.

6 years ago

Robyer
Member | 74
+
0
-

You have problem with Nette\Database\Connection vs. Nette\Database\Context. (you are creating new Context instead of new Connection)

6 years ago

enumag
Member | 2129
+
0
-

Looks wierd. Show us your configuration file (or it's relevant part).

6 years ago

Zdenal
Member | 21
+
0
-

My configuration file:

common:
	parameters:
		database:
			driver: mysql
			host: localhost
			dbname: cms
			user: root
			password: vertrigo

	php:
		date.timezone: Europe/Prague

	services:
		database:
			class: Nette\Database\Context
			arguments: [
				'%database.driver%:host=%database.host%;dbname=%database.dbname%',
				%database.user%,
				%database.password%
			]

		modelLoader:
			class:	ModelLoader
			arguments:	["@database"]

		authenticator: Authenticator

		authorizator:
			class: Nette\Security\Permission
			setup:
				- addRole('guest')
				- addRole('editor')
				- addRole('admin')
				- addResource('Admin:Default')
				- addResource('Admin:Pages')
				- addResource('Admin:Menu')
				- addResource('Admin:Articles')
				- addResource('Admin:News')
				- addResource('Admin:Eshop')
				- allow('editor', 'Admin:Default')
				- allow('admin')


production < common:

development < common:

6 years ago

David Grudl
Nette Core | 7068
+
0
-

Dokumentace je úplně na ho**o, připoj se k databázi tímto způsobem https://github.com/…g.local.neon a to services: database i @database vyhoď.

6 years ago

David Grudl
Nette Core | 7068
+
0
-

Oh, it seems that the documentation is not so bad;-) https://doc.nette.org/…/configuring#…