PHPackages                             hexblot/mssql-compat - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. hexblot/mssql-compat

ActiveLibrary[Database &amp; ORM](/categories/database)

hexblot/mssql-compat
====================

Small wrapper for PDO that emulates the deprecated mssql\_\* functions, and allows legacy software to work in PHP7+

v0.2.2(8y ago)83282[2 issues](https://github.com/hexblot/mssql-compat/issues)Apache-2.0PHPPHP &gt;=7.0.0

Since Aug 11Pushed 7y ago3 watchersCompare

[ Source](https://github.com/hexblot/mssql-compat)[ Packagist](https://packagist.org/packages/hexblot/mssql-compat)[ RSS](/packages/hexblot-mssql-compat/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (2)Used By (0)

MSSQL-Compat
============

[](#mssql-compat)

MSSQL Compat is a small and simple drop-in library that allows your pre-7 PHP project, that uses MSSQL via mssql\_\* functions ( eg mssql\_connect() et al ), to work transparently with PDO DBLib by providing the missing functions as wrappers around the equivalent PDO syntax - and all that with a single line!

The story
---------

[](#the-story)

I recently started migrating internal web applications to new servers that use PHP7.

Thus I stumbled on a couple of old applications that use MSSQL with PHP, which I dearly hoped to avoid rewriting and debugging now that PHP7 has deprecated the mssql\_\* family of functions.

*The result* is this single-file solution: just include it before your first mssql\_\* call, and it will transparently wrap them to the equivalent PDO calls.

What it is ***not***
--------------------

[](#what-it-is-not)

- This library is *not* a security enhancement by any measure. It assumes that your program logic escapes what needs to be escaped, since you cannot benefit from PDO goodness without changing the function syntax.
    - That being said, kindly let me know if you can provide better security in the given code.
- It is **not** meant as a means to develop new software in PHP7 using mssql\_\* functions - use PDO or similar!

Requirements
------------

[](#requirements)

MSSQL-Compat requires the bare basics for PHP7 to be able to talk to MSSQL - namely:

- [PHP7](http://php.net/)
- [PDO](http://php.net/manual/en/book.pdo.php) ( usually via the php-pdo package )
- [PDO DBLib](http://php.net/manual/en/ref.pdo-dblib.php) installed

> *Hint*: All of the above are easily usable via repos such as [IUS](https://ius.io/) or [Remi](http://rpms.famillecollet.com/)

How to use
----------

[](#how-to-use)

### Option A: Manually

[](#option-a-manually)

Just download and add an include to this library on the top of the old application `index.php` file.

```
