-
Notifications
You must be signed in to change notification settings - Fork 3
Multiple connections
Adam Patterson edited this page Dec 18, 2012
·
1 revision
Dingo supports multiple database connections in an application. To learn about configuring additional connections please see Database Configuration
.
To use a configured connection other than the defualt, simply add a third argument to the db()
function when you use it:
// Using connection "backup"
$data = db('mytable',NULL,'backup')->all();
You can also access a connection directly to run queries:
$con = db::connection('backup');
$res = $con->table('mytable')->all();
$con = db::connection('backup');
$res = $con->query('SELECT * FROM `mytable`');
It is possible to use any number of connections on a page. Connecting to an additional database will not disconnect any other previously active connections.