An Easy Way to Implement Namespaces in JavaScript | Home | Deposit-friendly Development

Filed under Quick Tips on June 9, 2008 by Ben Sgro

Getting started with PDO_MSSQL

The Zend framework requires that if you want  your application to work on both Windows and Linux, and take advantage of Zend's ORM (DB_Table_Abstract) functionality, you have to install and use the PDO_MSSQL driver.
    
  You can first try to install via PECL (however this didn't work in our case):

bens@arc90-dev-02:~/PDO_DBLIB-1.0$ sudo pecl install PDO_DBLIB
pear/PDO_DBLIB requires PHP extension "pdo" (version >= 1.0)
No valid packages found
install failed

bens@arc90-dev-02:~/PDO_DBLIB-1.0$ sudo pecl install PDO
Skipping package "pecl/PDO", already installed as version 1.0.3
No valid packages found
install failed


Instead, download the source and use phpize (which prepares the extension compiling) in the root directory of PDO:

bens@arc90-dev-02:~/PDO_DBLIB-1.0$ phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519

Then execute the configure script to build the pdo module.

bens@arc90-dev-02:~/PDO_DBLIB-1.0$ sudo ./configure 
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
...[removed for brevity]....
----------------------------------------------------------------------
Libraries have been installed in:
   /home/bens/PDO_DBLIB-1.0/modules


If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.

----------------------------------------------------------------------

If all went successful, you should see a similar message. Now, copy the module (pdo_dblib.so) from the build directory to your php directory:

bens@arc90-dev-02:~/PDO_DBLIB-1.0/modules$ sudo cp pdo_dblib.so /usr/lib/php5/20060613+lfs/
Then, copy the pdf_dblib.so to /usr/lib/php5/20060613+lfs/


Make a backup of your php.ini file and add the following to the php.ini file:

extension=pdo_dblib.so

Restart apache add the following to your config.ini in the Zend project you would like to use the PDO driver (on Linux):

database.adapter          = "pdo_mssql"
database.pdoType        = "dblib"

PDO should be setup and working. Enjoy.

Post a Comment Digg Del.icio.us

Trackback Pings (TrackBack URL for this entry)

http://www.arc90.com/cgi-bin/mt4/mt-tb.cgi/162.

Comments

I was planning on using PDO for my current project (and even wrote some code with it) until I found out that seeking to an arbitrary point in a result set wasn't possible. That is one feature that I like to have.

Posted on June 15, 2008 8:32 PM by Peter Goodman

How is the combo PHP on *nix plus SQL Server 2005 working out for you?

Posted on August 6, 2008 2:29 AM by Lukas

It works well - most of our applications get deployed to Windows - the WAMP stack has some limitations and we've had to jump over some hurdles to get things working properly.

Posted on August 6, 2008 9:25 AM by Ben Sgro

hi thanks for your blog post it really helped me, i just have one question what do you mean by:

[quote]
Restart apache add the following to your config.ini in the Zend project you would like to use the PDO driver (on Linux):

database.adapter         = "pdo_mssql"
database.pdoType       = "dblib"
[/quote]

Posted on October 24, 2008 7:44 PM by Mario

Post a Comment:

An Easy Way to Implement Namespaces in JavaScript | Main | Deposit-friendly Development