1
I have an app written on Laravel Framework 4.2, rotating in the PHP 5.6, in the Operating System Windows 7, connected to a mysql database, there was the need to make additional connection in another database to get specific information for this application, but all the connection attempts I tried were unsuccessful and return the following error message:
Pdoexception could not find driver
Below are the settings I made to try a multiple connection.
Filing cabinet: database php.
<?php
return array(
'fetch' => PDO::FETCH_CLASS,
'default' => 'mysql',
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => '192.168.10.10',
'database' => 'sistema',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
'sqlsrv' => array(
'driver' => 'sqlsrv',
'host' => '192.168.10.19',
'database' => 'ceps',
'username' => 'root',
'password' => 'root',
'prefix' => '',
),
),
'migrations' => 'migrations',
'redis' => array(
'cluster' => false,
'default' => array(
'host' => '127.0.0.1',
'port' => 6379,
'database' => 0,
),
),
);
Filing cabinet: Ceps.php
<?php
class Ceps extends Eloquent {
protected $connection = 'sqlsrv';
protected $table = 'ceps';
}
Filing cabinet: Homecontroller.php
<?php
class HomeController extends BaseController {
public function index()
{
$cep = DB::connection('sqlsrv')->select('cep', '=', '01003000')->get();
Log::info($cep);
return View::make('home',['title' => 'Home','menu' => 'home']);
}
}
I followed the guidelines available in the official documentation of Laravel 4.2, but I did not succeed in connecting to the second database.
https://stackoverflow.com/questions/31847054/how-to-use-multiple-databases-in-laravel See if this link can help you.
– Ricardo Lucas
I had already read and tried the procedures of this reply, but it also did not work, I tried again, in case I had "lost" some procedure, but still did not work.
– Leandro Paiva
I saw that sometimes there is problem when connecting with sqlsrv, make a connection only with this bank to see if the problem can be the drive.
– Ricardo Lucas
Your suggestion helped me find the solution to the problem, thank you.
– Leandro Paiva