I want to write the form result to another database.
In Concrete 5.6 you can switch to another database on the fly. I am unable to find out how this works in Concrete 5.7.
The 5.6 way
$db = Loader::db( 'newserver', 'newuser', 'newpassword', 'newdatabase', true);
It is possible to use the legacy Loader in Concrete 5.7. I tried to connect to the database but in the error you can see that it is still trying to use the default database.
$db = Database::get();
//tried this
$db = Loader::db('localhost', 'root', 'root', 'db_new', true);
//error
//db_original.db_new does not exist
What I recommend is that you set up another connection in application/config/database.php. So your config might then look something like this:
Then, when you are using your code you can access that connection at any time by doing the following:
EDIT: For those looking to change the type of database driver you will need to actually map a driver implementation in your config, which might look something like this: