Ticket #1572 (closed defect: fixed)
Connecting with to SQL server with ODBC
| Reported by: | jphilip | Owned by: | jwage |
|---|---|---|---|
| Priority: | major | Milestone: | 1.0.6 |
| Component: | Connection | Version: | 1.0.3 |
| Severity: | Keywords: | ||
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | yes |
Description (last modified by jwage) (diff)
The DB-Library that the current MSSQL adapter uses has a lot of problems and is not going to be supported in future versions of MSSQL. The PHP web site recommends using ODBC to connect to MSSQL, but I was not able to do it in Doctrine as it seems that the ODBC driver is not associated with a Doctrine_Connection implementation. I was able to connect with ODBC by associating ODBC with Doctrine_Connection_Mssql in the Manager openConnection method. (See patch) I also have to first create a PDO object and then pass it to Doctrine as ODBC allows passing a dsn without hostname and Doctrine does not. The following code works, but only with the joined patch as a quick fix:
$dbh = new PDO("odbc:localexpress"); $conn = Doctrine_Manager::getInstance()->connection($dbh, "db_import"); $conn ->setOption ('dsn', "odbc:localexpress");