JezK
Edit File: php.html
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>PHP</title><link rel="stylesheet" type="text/css" href="userguide.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="home" href="index.html" title="FreeTDS User Guide" /><link rel="up" href="software.html" title="Chapter 7. How to get what works with it working" /><link rel="prev" href="perl.html" title="Perl" /><link rel="next" href="Python.html" title="Python" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">PHP</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="perl.html">Prev</a> </td><th width="60%" align="center">Chapter 7. How to get what works with it working</th><td width="20%" align="right"> <a accesskey="n" href="Python.html">Next</a></td></tr></table><hr /></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="php"></a>PHP</h2></div></div></div><p>There are three options for building PHP with support for <span class="productname">FreeTDS</span> corresponding to the three <acronym class="acronym">API</acronym>s that <span class="productname">FreeTDS</span> supports: <code class="systemitem">DB-Library</code>, <code class="systemitem">CT-Library</code>, and <code class="systemitem">ODBC</code>. </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../images/note.gif" /></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>All these examples build the CGI version. Consult <a class="ulink" href="http://www.php.net/docs.php" target="_top">PHP's documentation</a> for building the Apache module and including other extensions.</p></td></tr></table></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="phpDblib"></a><code class="systemitem">DB-Library</code></h3></div></div></div><p>PHP can be configured with <code class="systemitem">DB-Library</code> access for a "Sybase" server (which also works with Microsoft servers), or with the <span class="emphasis"><em>mssql</em></span> extension, intended exclusively for Microsoft servers.</p><div class="example"><a id="e.g.PHP.dblib"></a><p class="title"><strong>Example 7.6. PHP and <code class="systemitem">DB-Library</code> for <span class="quote">“<span class="quote">Sybase</span>”</span></strong></p><div class="example-contents"><p>First build <span class="productname">FreeTDS</span> normally.</p><pre class="screen"> <code class="prompt">$ </code><strong class="userinput"><code>./configure --prefix=/usr/local/freetds</code></strong> <code class="prompt">$ </code><strong class="userinput"><code>make</code></strong> <code class="prompt">$ </code><strong class="userinput"><code>su root</code></strong> <code class="prompt">Password: </code> <code class="prompt">$ </code><strong class="userinput"><code>make install</code></strong></pre><p>Then build PHP with support for <span class="quote">“<span class="quote">Sybase</span>”</span></p><pre class="screen"> <code class="prompt">$ </code><strong class="userinput"><code>cd php</code></strong> <code class="prompt">$ </code><strong class="userinput"><code>./configure --with-sybase=/usr/local/freetds</code></strong> <code class="prompt">$ </code><strong class="userinput"><code>make</code></strong> <code class="prompt">$ </code><strong class="userinput"><code>su root</code></strong> <code class="prompt">Password: </code> <code class="prompt">$ </code><strong class="userinput"><code>make install</code></strong></pre><p>And that's it!</p></div></div><p><br class="example-break" /></p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="ctlib"></a><code class="systemitem">CT-Library</code></h3></div></div></div><p>Option 2 is to use the <code class="systemitem">CT-Library</code> <acronym class="acronym">API</acronym>. Again here, we run into minor difficulties at build time. Applications linking with Sybase's OpenClient have to link in a handful of libraries and these libraries vary slightly from platform to platform. When creating <span class="productname">FreeTDS</span> it was decided that there would be only one library: <code class="filename">libct</code>. This saves a great deal of library naming conflicts that Sybase ran into (e.g. <code class="filename">libtcl</code> is used both by Sybase and the language TCL), however some applications like PHP assume that all the Sybase libraries will be present. So, some hand editing of the Makefile is necessary to remove these extra libs. Build <span class="productname">FreeTDS</span> just as you would for <code class="systemitem">DB-Library</code> in <a class="link" href="php.html#phpDblib" title="DB-Library"> with <code class="systemitem">DB-Library</code></a>, above. Then configure PHP with <code class="systemitem">CT-Library</code>. </p><pre class="screen"> <code class="prompt">$ </code><strong class="userinput"><code>cd php</code></strong> <code class="prompt">$ </code><strong class="userinput"><code>./configure --with-sybase-ct=/usr/local/freetds</code></strong></pre><p> Now edit the <code class="filename">Zend/Makefile</code> looking for the <code class="literal">libZend_la_LDFLAGS</code> line and remove <code class="literal">-lsybtcl -lintl -lcomn</code> and <code class="literal">-lcs</code>, leaving the <code class="literal">-lct</code>. Then proceed to make and install PHP. </p><pre class="screen"> <code class="prompt">$ </code><strong class="userinput"><code>make</code></strong> <code class="prompt">$ </code><strong class="userinput"><code>su root</code></strong> <code class="prompt">Password: </code> <code class="prompt">$ </code><strong class="userinput"><code>make install</code></strong></pre><p> We hope an upcoming version of PHP will automatically detect the presence of <span class="productname">FreeTDS</span> and include only the <code class="literal">-lct</code> library.</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="ODBC"></a><code class="systemitem">ODBC</code></h3></div></div></div><p>The third and newest option is to use the <span class="productname">FreeTDS</span> <code class="systemitem">ODBC</code> driver with PHP. First build the <code class="systemitem">iODBC</code> or <code class="systemitem">unixODBC</code> driver manager and <span class="productname">FreeTDS</span> as detailed in <a class="xref" href="prepodbc.html" title="Chapter 4. Preparing ODBC">Preparing ODBC</a>. Then build PHP with support for ODBC. </p><pre class="screen"> <code class="prompt">$ </code><strong class="userinput"><code>cd php</code></strong> <code class="prompt">$ </code><strong class="userinput"><code>./configure --with-iodbc=/usr/local</code></strong> <code class="prompt">$ </code><strong class="userinput"><code>make</code></strong> <code class="prompt">$ </code><strong class="userinput"><code>su root</code></strong> <code class="prompt">Password: </code> <code class="prompt">$ </code><strong class="userinput"><code>make install</code></strong></pre><p> Now everything should run. There is a sample PHP script in the <span class="productname">FreeTDS</span> samples directory called <code class="filename">odbctest.php</code>.</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="perl.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="software.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="Python.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Perl </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Python</td></tr></table></div></body></html>