Skip to Content.
Sympa Menu

freetds - [freetds] FreeTDS and php_pdo

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Robin Smith" <Robin AT ndigital.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: [freetds] FreeTDS and php_pdo
  • Date: Fri, 04 Jul 2008 13:58:59 -0400

Hi,

Just wanted to send an email to summarize the "fun" I had trying to get
FreeTDS/UnixODBC working with PHP5 and PDO. I realize that this may not apply
to all and is somewhat OT for this list, but I'll summarize what I was trying
to do and where I had the problems in the interest of it being posted
somewhere. I fully understand that most of the issues I am having are NOT the
responsibility of the FreeTDS community, but they are related to the concept
of getting all this "open source stuff" working together :)

We are trying to standardize our Linux on SUSE Linux Enterprise Server
(SLES10). We are currently using MS-SQL2000 as our database backend.

First, SLES's standard PHP install does not include the php5-mssql module and
it also does not include FreeTDS (grrr), so I can't use their distributed
versions of PHP. So, I ended up getting RPMs from here:
http://download.opensuse.org/repositories/home:/civ75/openSUSE_10.3/
and was able to install PHP5, FreeTDS 0.64-5.1 and UnixODBC integration that
way.

Interesting Note: I submitted a bug in Novell's BugZilla about this and got a
reply from Matthias Eckermann (Senior Product Manager for SUSE Linux
Enterprise Server) stating:
> "Hello,
>
> FreeTDS and better integration with various database backends is
> on our evaluation list for SUSE Linux Enterprise 11.
>
> Yet, we are currently not planning to support FreeTSD in the
> SUSE Linux Enterprise 10 products family.
>
> As we are not tracking enhancements in bugzilla, you will see this
> bugzilla entry beeing closed as "FEATURE"."
Anyway, so I got this all working fine (using the "traditional" PHP mssql
functions to query MSSQL tables over FreeTDS/UnixODBC) , but then we decided
we wanted to standardize our PHP development on the Zend Framework. Zend uses
the php PDO module for database connectivity.

While PDO was available as an rpm, I could not find the driver needed to
enable PDO to connect to MSSQL. (apparently it can be done one of two or
three ways: PDO_DBLIB, PDO_ODBC, and PDO_MSSQL). I could not find PDO_MSSQL
for Linux anywhere; didn't like the PDO_ODBC route; so went with the most
often recommended PDO_DBLIB. However, as already mentioned, I could not find
a PDO_DBLIB rpm anywhere.

A little more hunting and I found that you can also install PHP modules with
PECL (the PHP Extension Community Library). So proceeded to try and install
PDO_DBLIB that way. I first had to remove the PDO rpm and instead install PDO
through PECL, which went well, but I could not get PDO_DBLIB to install
through PECL.

I think (but I am no developer guru) that this is a bug somewhere that does a
case sensitive check for the presence of "pdo", which it does not find (even
though "PDO" is installed - grrr). So, then I downloaded the PDO_DBLIB
extension source and tried to compile it manually:
You have to "phpize" the extension; then run "./configure"; then run "make",
then copy the .so out of the modules folder to the correct folder
(/usr/lib/php5/extensions/ on SLES); then load the module in the php.ini file.

However, when I ran ./configure, it would error out reporting that it could
not find "tds.h" in any standard locations, thus FreeTDS must not be install.
I hunted around some more and found a posting by Freddy explaining how to
create a "fake" tds.h and libtds.a to fool PHP into believing FreeTDS was
installed. My paths were different on SLES:
touch /usr/lib/libtds.a

touch /usr/include/tds.h
but this seemed to fix it. What surprised me was, this was a fix for 0.82,
but my rpm is 0.64-5.1 (there is no 0.82 rpm on the OpenSUSE build server
yet). Is this fix still the correct one for 0.64?

So its all up and running now, but it was a bit of an ordeal.

Sorry for the really long email, I just wanted to document it somewhere
public, and a few of the problems were related to FreeTDS integration
(although blame-able on non-FreeTDS projects).

Thanks for listening. Any comments on what I ended up doing would be
appreciated.

Thanks

Robin
-----------------------
Robin Smith

Senior Manager, Information Technology
NDI
103 Randall Drive
Waterloo, ON, Canada N2V 1C5
Telephone: +1 (519) 884-5142 ext. 224
Toll Free: +1 (877) 634-6340
Global: ++ (800) 634-634-00
Facsimile: +1 (519) 884-5184
Website: www.ndigital.com ( http://www.ndigital.com/ )
----------------------




Archive powered by MHonArc 2.6.24.

Top of Page