Question
Explain the difference between 'sqlsrv' and 'pdo_sqlsrv' extensions and which one is more suitable when I am facing the 'undefined function sqlsrv_connect()' error.
Asked by: USER7147
164 Viewed
164 Answers
Responsive Ad After Question
Answer (164)
'sqlsrv' is the older, direct SQL Server driver. 'pdo_sqlsrv' is a PDO (PHP Data Objects) driver for SQL Server, providing a database abstraction layer. If you're getting the 'undefined function' error for `sqlsrv_connect()`, you should install and enable the 'sqlsrv' extension. PDO_sqlsrv would require installation and enabling of that specific driver and the corresponding PDO extension. If you are already using PDO, using `pdo_sqlsrv` might be a cleaner solution for database portability if you may migrate to a different type of database.