using doctrine 2 with SQL Server

坚强是说给别人听的谎言 提交于 2020-01-14 06:14:13

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/3263411/using-doctrine-2-with-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!