how to connect to another database on the same server

Notice: This thread is very old.
ManSlayer
Member | 2
+
0
-

hi, i want to change database on the same server where i have the first db.. in config i have this:

database:
dsn: 'mysql:host=xxx;dbname=account'
user: xxx
password: xxx

can i connect to another database in presenter?

japlavaren
Member | 404
+
+2
-

you should use different database section: nette.database.default is for default connection

ManSlayer
Member | 2
+
0
-

how to do it?

Filip Procházka
Moderator | 4668
+
+6
-

You have to configure your connections like this

database:
	default:
		dsn: 'mysql:host=xxx;dbname=account'
		user: xxx
		password: xxx

	another:
		dsn: 'mysql:host=xxx;dbname=account'
		user: xxx
		password: xxx

And then you pass the connections to your services

services:
	- App\ArticlesModel(@nette.database.default)
	- App\DataImportModel(@nette.database.another)

Last edited by Filip Procházka (2014-07-27 23:15)