Access external database

If you wish to access an external database either with the ORM or with a direct DB::Query you can...

$otherDatabaseConfig = array(
    "type"      => 'MySQLDatabase',
    "server"    => 'localhost',
    "username"  => 'new_user',
    "password"  => 'xxxx',
    "path"      => '',
    "database"  => 'new_database'
);
DB::connect($otherDatabaseConfig);

//Use ORM to write if table structure is the same
//Or use DB::Query to access / update any table 

//revert to normal credentials

global $databaseConfig;
DB::connect($databaseConfig);

Rate this post

Post your comment

Comments

No one has commented on this page yet.

RSS feed for comments on this page | RSS feed for all comments