Is it possible to connect with multiple databases?

Is it possible to connect with multiple databases? Can i add multiple connections in the config-file somehow?

thanks

You can connect to multiple database, yes, but I don’t think you can set multiple connections in the config (unless you define your own connections to use with $database->connect()).

If it’s a test DB and a Live DB you are talking about, you can connect to them via domain based configs, which will allow different connections based on the domain name the site is running on.

Thanks, I’ll do a test with the database class.

Hi, Can you set such a domainbased config in kirby? Or how do you do that?

So basically, you probably have a config.php file already. All you do is copy it and rename it to config.yourdomainname.com.php or config.subdomain.yourdomainname.com.php.

It’s inheritive. You do not need to redeclare eveything, only the stuff you want to overide. It reads the config.php + the domain config. if you have reset something in the domain config, it will take precedence over the setting in config.php.

See here for more info:

2 Likes