Search code examples
phppdofreetds

How to change PHP's PDO dblib to updated FreeTDS?


We updated FreeTDS on our CentOS box and can connect using tsql cli. Before the update, tsql -C reported 0.91 and now it reports 0.95.

The new versions is using a freetds.conf found in /usr/local/etc instead of the old /etc/ directory.

PHP using PDO is still referencing the old freetds and the old freetds.conf. I know this because changing the old freetds.conf is still affecting our PHP scripts/

How do we get PHP and PDO to use the new freetds.


Solution

  • You have a few options.

    • Copy the old version in /etc to the new location 0.95 is looking for in /usr/local/etc
    • Make a symbolic link to the old location from the new: ln -S /etc/freetds.conf /usr/local/etc/freetds.conf
    • FreeTDS also looks for a .freetds.conf (notice the "." at the beginning) in the home directory of the current user. You could put a .freetds.conf into the directory of the user your web server runs as.
    • Finally, you could compile from source if you want version 0.95, passing the option --sysconfdir /etc to the configure command before compiling.

    More info: http://www.freetds.org/userguide/freetdsconf.htm

    Good luck!