Executing Microsoft SQL Server Stored Procedure from PHP on Linux
Learn how to setup, install and configure Apache and PHP on a Linux box to execute MS SQL stored procedures. This extensive article takes you through an in-depth look on how to achieve your ideal environment.
Executing Microsoft SQL Server Stored Procedure from PHP on Linux - Conclusion (Page 9 of 9 )
In this article, we discuss how to make Apache, PHP and FreeTDS work together, executing Microsoft SQL Server stored procedures from Red Hat Linux 9.0. Due to a bug in the FreeTDS original source code, mssql_bind(), mssql_execute(), and mssql_init() do not work with the default installation. We give out a workaround to modify the PHP source code so that these functions work successfully.
This is also tested for PHP 4.3.2 with Apache 2.0.46, and FreeTDS 0.61.2 on Red Hat 9.0. I would suggest you to try this on Red Hat 8.0 and 7.3. The following is the testing environment I used for this article:
The Machines for Red Hat 9.0 Are: Dell Dimension 4500 (2.4 GHz P4, 1 GB RAM) with Apache 2.0.47 + FreeTDS 0.61.2 + PHP 4.3.3 installed
IBM ThinkPad T30 Laptop (1.8 GHz P4, 512 MB RAM), with Apache 2.0.46 + FreeTDS 0.61.2 + PHP 4.3.2 installed
The Machine for Windows Apache Is: Same laptop as above (dual boot) with Windows XP + Apache 2.0.46 (precompiled binary) + PHP 4.3.2 (precompiled binary)
The Machine for MS SQL Server 2000: Compatible PIII 1 GHz, 512 MB RAM with Windows 2000 Server installed.
It is really worthy to be mention that you cannot compile Sybase or Sybase_CT module with Microsoft SQL Server Module together without modification. If you decide to use Sybase or Sybase_CT module, mssql_xxx functions are still functional except these 4 functions: mssql_bind(), mssql_execute(), mssql_init() and mssql_free_statment(), because mssql_xxx functions are treated as aliases of corresponding Sybase_xxx.
A workaround to keep these 4 functions is to remove the mssql alias definition in Sybase and Sybase_CT module from the function_entry part in php_sybase_ct.c or php_sybase_db.c files. Recompile PHP with sybase_ct and mssql options.
Iíve provided a real sample here (I have Sybase Adaptive Server Enterprise 12.5 developer edition and Oracle Enterprise Server 8.1.7 installed on Red Hat 9.0):
Repeat the steps in this article to install PHP, and remember to restart Apache. You will see sybase_ct and mssql modules co-exist in PHP from the test.php page on Linux.
On Windows, after removing the mssql alias definition in Sybase_CT module, use Visual C++ 6.0 to recompile and make a new php_sybase_ct.dll (you must at least have the Sybase Open Client installed on your Windows machine to access the header files and library files). Then copy php_sybase_ct.dll to your php extensions directory, uncomment the following 2 lines in your php.ini file:
Restart and you will see sybase_ct and mssql modules co-existing in PHP from test.php on Windows.
In my next article, Executing Sybase SQL Server Stored Procedure from PHP, I will discuss how to expand PHP Sybase DB and Sybase CT functions by yourself, adding the exact same functions like: sybase_bind(), sybase_execute(), sybase_init() and sybase_free_statment() into the PHP Sybase and Sybase_CT modules.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.