This may help someone..
MSSQL
The Moodle 2.5 installation docs here: http://docs.moodle.org/25/en/Installing_MSSQL_for_PHP warns against using the Microsoft drivers for SQL Server for PHP as it has known problems and is therefore not suitable for production servers.
Issue: https://tracker.moodle.org/browse/MDL-37734 (Still current as of July 2013)
“This issue is about to describe the problem happening with current sqllrv moodle driver (using the MS driver for PHP) to use Moodle under SQL*Server databases.
Along the last months, it has been reported in various issues, in different places, and it's affecting more and more, while we add more transactions to code base.”
Workaround: (use FreeTDS instead, while this gets fixed)
Supported Versions:
Microsoft Drivers 3.0 for PHP for SQL Server provides a self-extracting executable file which provides thread-safe and non-thread-safe drivers for PHP 5.3 and 5.4. http://www.microsoft.com/en-gb/download/details.aspx?id=20098. A Microsoft employee has released version 3.0.2 for PHP 5.5 here: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/e1d37219-88a3-46b2-a421-73bfa33fe433/unofficial-php-55-drivers-x86
FreeTDS
The Moodle 2.5 installation docs here http://docs.moodle.org/25/en/Installing_MSSQL_for_PHP list various FreeTDS binaries for download from PHP version 5.2.x --> 5.4.x. No binaries exist for 5.5 on that page for download. To use PHP 5.5 a custom build is required.
Build process
Building PHP 5.5.1 with FreeTDS 0.91.89 for moodle 2.5.1 under x86 vc11
Requirements:
- Visual C 11 (Visual Studio 2012) (Express version OK) (Windows SDK not required)
- Current stable PHP source (http://php.net/downloads.php)
- Current stable FreeTDS source (ftp://ftp.freetds.org/pub/freetds/stable/)
- Most recent binary tools (http://windows.php.net/downloads/php-sdk/)
- PHP dependencies (http://windows.php.net/downloads/php-sdk/)
Setup PHP environment by following guide:
https://wiki.php.net/internals/windows/stepbystepbuild
- In step 8, bin\phpsdk_buildtree.bat did not create the vc11 folder so I just copied the vc9.
Ensure you can build PHP under this created environment using:
buildconf
configure --disable-all --enable-cli
nmake
Now loosely follow the instructions on building FreeTDS here:
http://docs.moodle.org/dev/Compiling_FreeTDS_under_Windows
Building FreeTDS
If when attempting to build php_dblib.lib from source you get linking errors, it is probably because you are missing some source files in the projects/solutions. Doing a file search in the src folder for the symbol (without the preceding underscore) should highlight where the function definition comes from. Add the file to the project that won’t compile. Rinse and Repeat.
Linking errors: http://permalink.gmane.org/gmane.comp.db.tds.freetds/11009
When php_dblib.lib is compilied and in the php lib folder in your build environment, the last thing is to configure the makefile appropriately. (You may also need to compile libTDS.lib from FreeTDS - I had to.).
I used a number of different configurations while testing. This one worked:
configure --disable-all --disable-zts --enable-cli --with-dblib=shared --with-extra-includes=C:\php-sdk\phpdev\vc11\x86\php-5.5.1-src\freetds\include;C:\php-sdk\phpdev\vc11\x86\php-5.5.1-src\freetds\win32
Check the output from the configure call in case there any skipped dependencies. (like dblib!)
“--with-dblib=shared” is the key line for actually telling make to create an external dll file and not just compile the functionality directly into PHP core.
If while using nmake an unresolved external symbol linker error is reported: e.g. “error LNK2019: unresolved external symbol _tdsdump_log referenced in function _dblib_add_connection” you may need to add libTDS.lib to the libs statement in makefile and rerun make.
http://enyby.blogspot.co.uk/2013/01/eliminate-errors-compile-freetds-on.html. I had to do this.
Use “--enable-zts” or --disable-zts” for thread safety as mentioned.
Then when php_dblib.dll is created put it in the ext folder in your run time environment and enable the extension in your php.ini and you’re good to go!
Environment variables with IIS
One last consideration is the location of your freetds.conf file. If your server will only need one freetds.conf file then you can just use a server environment variable. Other wise you will need to add environment variables to the FastCGI Settings for PHP in IIS. Remember that the FREETDS variable is a path, and not a filename! I did not remember this!