Laravel 4 still does not support ODBC directly, you'll have to do it yourself or you can try to use this driver: https://github.com/ccovey/odbc-driver.
You'll have to add connection that should look something like:
'odbc' => array(
'driver' => 'odbc',
'dsn' => 'Driver={iSeries Access ODBC Driver};System=my_system_name;',
'grammar' => 'DB2',
'username' => 'foo',
'password' => 'bar',
'database' => '',
'grammar' => 'SqlServerGrammar',
),
As noted in the package docs, you have to provide a valid DSN to connect to your server: those ones are examples of valid connection strings:
"Driver={SQL Server};Server=(local);Trusted_Connection=Yes;Database=AdventureWorks;"
"Driver={Microsoft ODBC for Oracle};Server=ORACLE8i7;Persist Security Info=False;Trusted_Connection=Yes"
"Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\bin\Northwind.mdb"
"Driver={Microsoft Excel Driver (*.xls)};DBQ=c:\bin\book1.xls"
"Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=c:\bin"
To know if your DSN is valid, you better test the DNS outside Laravel.
If you have access to a Linux, you can test it by doing:
apt-get install unixodbc
isql -v DSN_NAME db_username db_password
And it should answer with:
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
There's a bug in ccovey's source code and, for now, you should alter the source of ODBCDriverConnection
to:
/**
* Default grammar for specified Schema
* @return Schema\Grammars\Grammar
*/
protected function getDefaultSchemaGrammar()
{
return $this->withTablePrefix(new \Illuminate\Database\Schema\SqlServerGrammar);
}
I'll open an issue in the package Github so they get this fixed.