sqlshim - PHP sqlsrv for Linux/OS X
The sqlshim project aims to replicate Microsoft SQL Server Driver for PHP (sqlsrv) on Linux/OS X.
sqlshim was conceived out of the need for sqlsrv (a Windows-only PHP extension) in an OS X development environment. It began as a short script that defined a small set of functions. Unfortunately,
DISCLAIMER: sqlshim is in alpha and is geared primarily toward use in a development environment. It is provided as-is and without warranty. I will not be held responsible for any damage(s) incurred from its use.
\RadSectors\SqlShim::init();
sqlsrv_connect( ... );
- ???
- Profit!!
The project's aim is to completely and accurately replicate the provisions of sqlsrv. Any official sqlsrv documentation should suffice.
Microsoft SQL Server Driver - PHP.net
SQLSRV Driver API Reference - MSDN
composer require "radsectors/sqlshim:dev-master"
- Include autoloader.
require 'vendor/autoload.php';
- Download the latest release.
- Extract
src/sqlshim.php
andsrc/globals.php
to wherever you store your 3rd-party libraries. - Include
sqlshim.php
.
require '/path/to/sqlshim.php';
Please see wiki article.
Please see PHP.net's article on sqlsrv_connect()
Please see wiki article
See CONTRIBUTING.md for instructions on how to contribute.
You can hit me up on twitter @radsectors.
Please visit the project on GitHub to view outstanding issues.
sqlshim is licensed under the MIT license. See the LICENSE file for details.
#DBLIB Based Version (dexterfichuk)
I've been using this for awhile and performed some changes to the original one. The original copy is indeed great the way it is for some, but this one has some significant changes. Below are a few of the fundamental changes, but I've done other various tweaks to get it up and working for myself.
- Changed from the ODBC PDO driver to use DBLIB, couldn't connect with ODBC
- Rewrote the parameter function, as it wouldn't pass in any parameters for me.
- Had to rewrite a converter for datatypes. With DBLIB connections everything is returned as a string, so this will fix numbers and bool's into the proper format.
- May now be dependent on a few more packages
- Forces the use of FreeTDS 7.2
- The original sqlshim can't retrieve the "text" datatype, and any query which calls a text type field will be cut off and return null fields thereafter. The DBLIB driver however does not have this problem.
- Parameters work whereas they did not for me prior.
- Stored parameters always work because of forced FreeTDS version.
- Retrieves dates as strings
- Weird memory leak errors if using on PHP 5.5.19 or lower. I recommend using PHP 5.6.23. The warnings do not affect performance and are just a PHP bug if you remain on a lower PHP version.