15
I need to connect a database SQL Server 2008 in Laravel 4. I have been researching and I did not find solution for the scenario in which I am.
I’m using Laravel using the XAMPP (PHP 5.5.6 --with-mssql) package on MAC OS X 10.9 with Freetds working perfectly when I use php’s mssql_* functions in other applications where I don’t use Laravel.
When I make a simple query to BD SQL I get the following error:
Pdoexception: could not find driver
My setting in /app/database.php is this way:
'default' => 'sqlsrv',
'sqlsrv' => array( 'driver' => 'sqlsrv', 'host' => 'ip do servidor', 'database' => 'nome da base', 'username' => 'sa', 'password' => 'senha', 'prefix' => '', ),
[Edited]
In php.ini, I decoded the line:
extension=php_pdo_mssql.dll
However, checking the PHP documentation found the information: "The PDO_SQLSRV Extension is only compatible with PHP running on Windows. For Linux, see ODBC and » Microsoft’s SQL Server ODBC Driver for Linux.", or do I have to use the connection via an ODBC Driver? Can’t use Freetds on Laravel?
I upgraded Native Client on Server with SQL 2008 to version 11.
I am still unsuccessful. Could someone help me?
In the
phpinfo()
, the extension PDO_SQLSRV appears enabled?– rray
No. In phpinfo() -> API Extensions, only: mysqli,mysql,pdo_mysql.
– leirbag
Here’s the problem, either the extension is commented on in your php.ini, or it’s not installed.
– Brayan
I decoded the line Extension=php_pdo_mssql.dll, but mssql does not appear in the PDO’s list in phpinfo()
– leirbag
Any error message? a dll is in the folder
ext
?– rray
I don’t get any error message when starting Apache...
– leirbag
No use trying to use DLL in OSX. I think you’ll need to recompile php...
– bfavaretto
Trying to help (in English): http://stackoverflow.com/questions/13371281/how-can-i-connect-to-sql-server-from-a-mac-with-php-pdo
– bfavaretto
Thanks @bfavaretto, your comment cleared up a few things and I think I’m close to finding the solution. Has anyone been in the same situation as this and requested changes in Laravel repository in Git. Now I need to find out how Laravel 4 manipulates these parameters in DB config.
– leirbag