This is a Laravel 5 class that I have at the location app/Database/OTF.php
and use to connect to different databases on the fly.
// Using the same host/password/etc, just changing databases
$otf = new App\Database\OTF(['database' => 'kittens']);
// Get the users table
$users = $otf->getTable('users');
// Find the first user in the table
$first_user = $users->first();
Hey @harrisoftware, I'm actually not sure why
->get()
would not work for you. I just tried both->get()
and->take(10)->get()
and they both work fine for me.I do notice an error in your code block, but that might have just been a typo in your comment:
If you're receiving a PDO exception I'd say look into that and see what the problem is and then try again!