PHP
  Home arrow PHP arrow Page 9 - Executing Microsoft SQL Server Stored Proc...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Executing Microsoft SQL Server Stored Procedure from PHP on Linux
By: Jack Zhang
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 31
    2003-10-20

    Table of Contents:
  • Executing Microsoft SQL Server Stored Procedure from PHP on Linux
  • Preparation
  • Installing the Apache Web Server
  • Installing the Apache Web Server, Cont'd
  • Installing FreeTDS
  • Modify the PHP Source Code
  • Modify the PHP Source Code, Cont'd
  • Executing MS SQL Server Procedures from PHP
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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):

    ./configure --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --target=i686-redhat-linux-gnu --prefix=/usr/local/php2 --with-config-file-path=/usr/local/php2  --enable-force-cgi-redirect --disable-debug --enable-pic --disable-rpath --enable-inline-optimization  --with-db4 --with-dom=/usr --with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-png-dir=/usr --with-gd --enable-gd-native-ttf --with-ttf --with-gdbm --with-gettext --with-ncurses --with-gmp --with-iconv --with-jpeg-dir=/usr --with-openssl --with-png --with-ming --with-regex=system --with-xml --with-expat-dir=/usr --with-zlib --with-layout=GNU --enable-bcmath --enable-exif --enable-ftp --enable-magic-quotes --enable-safe-mode --enable-sockets --enable-sysvsem --enable-sysvshm --enable-discard-path --enable-track-vars --enable-trans-sid  --enable-wddx --with-oci8=/home/oracle/product/8.1.7 --enable-sigchild  --with-mssql=/usr/local/FreeTDS --with-sybase-ct=/opt/sybase-12.5/OCS-12_5 --with-pcre-regex --with-mysql=/usr/local/mysql --with-pgsql=/usr/local/pgsql --with-imap=shared --with-imap-ssl --with-kerberos=/usr/kerberos --enable-memory-limit --enable-bcmath --enable-shmop --enable-versioning --enable-calendar --enable-dbx --enable-dio --enable-mcal  --disable-cli --with-apxs2filter=/usr/local/Apache2/bin/apxs

    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:

    extension=php_sybase_ct.dll
    extension=php_mssql.dll

    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.

    Reference Sites, Books and Articles:


    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.

     

    PHP ARTICLES

    - Making Usage Statistics in PHP
    - Installing PHP under Windows: Further Config...
    - File Version Management in PHP
    - Statistical View of Data in a Clustered Bar ...
    - Creating a Multi-File Upload Script in PHP
    - Executing Microsoft SQL Server Stored Proced...
    - Code 10x More Efficiently Using Data Access ...
    - A Few Tips for Speeding Up PHP Code
    - The Modular Web Page
    - Quick E-Commerce with PHP and PayPal
    - Regression Testing With JMeter
    - Building an Iterator with PHP
    - PHP Frontend to ImageMagick
    - Using PEAR's mimeDecode Module
    - Incoming Mail and PHP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek