Download the PHP package hexblot/mssql-compat without Composer
On this page you can find all versions of the php package hexblot/mssql-compat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hexblot/mssql-compat
More information about hexblot/mssql-compat
Files in hexblot/mssql-compat
Package mssql-compat
Short Description Small wrapper for PDO that emulates the deprecated mssql_* functions, and allows legacy software to work in PHP7+
License Apache-2.0
Informations about the package 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
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
- 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
MSSQL-Compat requires the bare basics for PHP7 to be able to talk to MSSQL - namely:
Hint: All of the above are easily usable via repos such as IUS or Remi
How to use
Option A: Manually
Just download and add an include to this library on the top of the old application index.php
file.
Option B: Via Composer
If your app doesn't already have one, add a require towards the autoload.php
file generated by composer in your index.php
:
Under the hood: Which functions are covered
This is the list of the functions that are currently covered. They were sufficient for my needs, but, understandably, you may need more for your projects. Let me know in the issues - patches are of course very welcomed!
- [ ] mssql_bind
- [x] mssql_close
- [x] mssql_connect
- [ ] mssqldataseek
- [ ] mssql_execute
- [x] mssqlfetcharray
- [x] mssqlfetchassoc
- [ ] mssqlfetchbatch
- [x] mssqlfetchfield
- [x] mssqlfetchobject
- [x] mssqlfetchrow
- [x] mssqlfieldlength
- [x] mssqlfieldname
- [x] mssqlfieldseek
- [ ] mssqlfieldtype
- [x] mssqlfreeresult
- [ ] mssqlfreestatement
- [x] mssqlgetlast_message
- [x] mssqlguidstring
- [ ] mssql_init
- [x] mssqlminerror_severity NOTE: Placeholder only to avoid errors!
- [x] mssqlminmessage_severity NOTE: Placeholder only to avoid errors!
- [ ] mssqlnextresult
- [x] mssqlnumfields
- [x] mssqlnumrows
- [x] mssql_pconnect
- [x] mssql_query
- [ ] mssql_result
- [x] mssqlrowsaffected
- [x] mssqlselectdb
All versions of mssql-compat with dependencies
ext-pdo Version *