Search code examples
phpodbcphp-7.1

PHP 7 - ODBC Support is built in...or is it?


The stock php.ini file for php 7 declares in a comment:

"Note that ODBC support is built in, so no dll is needed for it."

However, a few lines down there is:

extension=php_odbc.dll

...and that file is included in the ext directory.

We support applications with different versions of php and I've noticed older versions don't include the extension in their respective .ini files, or the .dll in their ext directories, yet connecting to odbc works as stated in the .ini file comments.

In php 7, if I remove either the extension in the ini file or physically move/delete the .dll file and try running, I get:

Fatal error: Uncaught Error: Call to undefined function odbc_connect()

The question: does php 7 actually have odbc support "built in" as the ini file claims? If so, why is it behaving this way when older versions behave differently? If not, why does the ini file claim that it does, and where is the documentation to the contrary?

PHP Version: 7.1.1

OS: Windows 10 Enterprise 64-bit

Thanks!


Solution

  • I suspect this used to be true but it's no longer the case since PHP/7.x, at least in official Windows binaries. Now there's definitively an "ext/php_odbc.dll" file that needs to be loaded—and the line needs to be added since it isn't already commented out in the templates:

    extension=php_odbc.dll
    

    I reported it as documentation problem and it was fixed two hours later. PHP/7.1.16 and PHP/7.2.5 already include the fix.