using doctrine 2 with SQL Server

2019-06-14 17:48发布

I need to migrate an existing project, built on the current beta of doctrine 2, from mysql to SQL Server.

I have complete control of the SQL Server.

In the DBAL Folder of Doctrine there already is a PDOMsSql driver, but I can't figure out, how to use it. (there is still no documentation)

Doctrine also offers two other ways, I could maybe use:

  • driverClass: Specifies a custom driver implementation if no 'driver' is specified. This allows the use of custom drivers that are not part of the Doctrine DBAL itself.
  • pdo: Specifies an existing PDO instance to use.

Could anyone help me with this? I have no clue how to start here, since I have no experience with ODBC/PDO and SQL Server at all.

2条回答
Root(大扎)
2楼-- · 2019-06-14 18:17

You can also use sqlsrv or pdosqlsrv now. I submitted changes to the pdosqlsrv driver in the Doctrine DBAL project today that fix some things with the DSN creation and get it working. Sqlsrv/pdosqlsrv is probably the way to go imo since Microsoft is actively developing it.

查看更多
我想做一个坏孩纸
3楼-- · 2019-06-14 18:20

I figured it out by myself... on a mac, "mssql.so" does only provide "dblib:" as a driver. So by replacing dbo_mssql in the Doctrine Driver with "dblib", defining a FreeTDS host and using its name as the hostname for my connection, everything works fine.

查看更多
登录 后发表回答