4.0.4 release

This commit is contained in:
Meet Bhagdev 2016-09-13 14:44:45 -07:00
parent 16e0b1ccf2
commit 4ccffbbe07
30 changed files with 217 additions and 119 deletions

View file

@ -1,6 +1,6 @@
#PHP Linux Drivers for SQL Server - Installation Tutorial
In this tutorial, we will show you how to install the PHP Linux drivers for Microsoft SQL Server, along with the additional required software to get them to work. The drivers are available from GitHub, where you will find several variants. They are available as a SQLSRV variant or a PDO_SQLSRV variant, the latter implements PDO PHP extension for accessing data. In addition, the drivers are built for both thread safe and non-thread safe environments. The PHP Linux drivers built for thread safe servers are named php_sqlsrv_7_ts.so and php_pdo_sqlsrv_7_ts.so. The drivers built for servers without thread safety enabled are php_sqlsrv_7_nts.so and php_pdo_sqlsrv_7_nts.so.
In this tutorial, we will show you how to install the PHP Linux drivers for Microsoft SQL Server, along with the additional required software to get them to work. The drivers are available from Github, where you will find several variants. They are available as a SQLSRV variant or a PDO_SQLSRV variant; the latter implements the PDO PHP extension for accessing data. In addition, the drivers are built for both thread safe and non-thread safe environments. The PHP Linux drivers built for thread safe servers are named php_sqlsrv_7_ts.so and php_pdo_sqlsrv_7_ts.so. The drivers built for servers without thread safety enabled are php_sqlsrv_7_nts.so and php_pdo_sqlsrv_7_nts.so.
Prior to installing the PHP Linux drivers, you must install the unixODBC driver manager, the Microsoft ODBC driver for Linux, PHP 7, and a web server. In the following, we will assume the web server is Apache.
@ -86,12 +86,10 @@ Now you are ready to install PHP. You can install by source or, if the packaged
`./buildconf --force`
3. Run `./configure` with the following options on the command line:
a. `LIBS=-lodbc`
b. the path for the unixODBC header files using `--with-unixODBC=<path-to-ODBC-headers>`. To find the path for the header files, use the command `sudo find / -name sql.h`. Then add this path, without the /include/sql.h, to the command line. For example, if the find command yields `/usr/include/sql.h`, add `--with-unixODBC=/usr` to the `./configure` command line.
c. the path to apxs or apxs2 to configure PHP for Apache using --with-apxs2=<path-to-apxs>. To find the path to apxs (or apxs2), run `sudo find / -name apxs` or `sudo find / -name apxs2` and add the resulting path to the option.
d. if your web server has thread safety enabled, add `--enable-maintainer-zts` to `./configure`. Otherwise you may omit this option.
a. the path to apxs or apxs2 to configure PHP for Apache using `--with-apxs2=<path-to-apxs>`. To find the path to apxs (or apxs2), run `sudo find / -name apxs` or `sudo find / -name apxs2` and add the resulting path to the option. For example, if the find command yields `/usr/bin/apxs2`, add `--with-apxs2=/usr/bin/apxs2` to the `./configure` command line.
b. if your web server has thread safety enabled, add `--enable-maintainer-zts` to `./configure`. Otherwise you may omit this option.
Thus your ./configure command should look like `./configure LIBS=-lodbc --with-unixODBC=<path-to-ODBC-headers> --with-apxs2=<path-to-apxs-executable> --enable-maintainer-zts`.
Thus your `./configure` command should look like `./configure --with-apxs2=<path-to-apxs-executable> --enable-maintainer-zts`.
[![pic5](https://msdnshared.blob.core.windows.net/media/2016/07/image510.png)](https://msdnshared.blob.core.windows.net/media/2016/07/image510.png)
@ -114,26 +112,31 @@ Now you are ready to install PHP. You can install by source or, if the packaged
###Install PHP from the package manager
To install PHP and the PHP apache module using your package manager,
you must ensure that your distribution provides PHP 7, as earlier versions will not work.
NOTE: Installing PHP from package requires installing php-odbc for symbol definitions. However, php-odbc uses a different version of unixODBC from the one obtained when following the instructions above. As mentioned, we do not recommend using your package manager's version of unixODBC, and we cannot guarantee that the functionality obtained installing PHP this way will be the same as when installing PHP from source.
To install PHP and the PHP apache module using your package manager, you must ensure that your distribution provides PHP 7, as earlier versions will not work.
Follow these steps to install from the package manager on Ubuntu:
1. Run `apt-cache show php | grep Version`. The output will look like Version: 1:7.0+35ubuntu6\. The actual version of PHP immediately follows the 1: .
2. Run `sudo apt-get install php php-odbc libapache2-mod-php` to install PHP, the php-odbc module, and the Apache module.
1. Run `apt-cache show php | grep Version`. The output will look like Version: 1:7.0+35ubuntu6\. The actual version of PHP immediately follows the 1: .
2. If the packaged PHP version is not PHP 7.0, you can add the [Ondrej PPA repository](https://launchpad.net/~ondrej/+archive/ubuntu/php) to install it. Run `sudo add-apt-repository ppa:ondrej/php` and then `sudo apt-get update`.
3. Run `sudo apt-get install php libapache2-mod-php` to install PHP and the Apache module.
Follow these steps to install from the package manager on Red Hat/CentOS:
1. Run `yum info php | grep Version` and verify that the version is at least 7.0.
2. Run `sudo yum install php php-odbc` to install PHP, the php-odbc module, and the Apache module.
1. Run `yum info php | grep Version` and verify that the version is 7.0.
2. If the packaged PHP version is not PHP 7.0, you can add a new repository to install it. We recommend using the [Remi RPM repository](http://blog.remirepo.net/post/2016/02/14/Install-PHP-7-on-CentOS-RHEL-Fedora). To configure this repository, run
`wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm`
`wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm`
`rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm`
`yum-config-manager --enable remi-php70`
3. Run `sudo yum install php` to install both PHP and the Apache module.
###Compiling and installing Microsoft PHP drivers for SQLServer from source:
Instead of using the precompiled binaries, you can compile your own when compiling PHP. To compile the binaries yourself, follow these steps:
1. Download the source from github. Download the latest stable PHP 7 source from http://php.net/.
1. Download the source from Github. Download the latest stable PHP 7 source from http://php.net/.
2. Unpack the PHP source and the SQL Server extension source, and copy the extension source to the PHP extension directory:
@ -150,7 +153,7 @@ Instead of using the precompiled binaries, you can compile your own when compili
c. `--with-pdo_sqlsrv=shared`
d. `--with-odbcver=0x0380`. This option has no practical effect as the drivers use ODBC version 3.52, but it suppresses compilation warnings arising from the fact that PHP's default setting of version 3.00 is different from unixODBC's setting of 3.80.
Thus your `./configure` command should look like `./configure LIBS=-lodbc --with-unixODBC=<path-to-ODBC-headers> --with-apxs2=<path-to-apxs-executable> --disable-maintainer-zts CXXFLAGS=-std=c++11 --enable-sqlsrv=shared --with-pdo_sqlsrv=shared --with-odbcver=0x0380`.
Thus your `./configure` command should look like `./configure --with-apxs2=<path-to-apxs-executable> --disable-maintainer-zts CXXFLAGS=-std=c++11 --enable-sqlsrv=shared --with-pdo_sqlsrv=shared --with-odbcver=0x0380`.
Note: if you get a message saying `WARNING: unrecognized options: --enable-sqlsrv, --with-pdo_sqlsrv`, run `touch ext/*/config.m4` and then `./buildconf --force` before trying `./configure` again.
@ -169,7 +172,7 @@ Now edit your `php.ini` file to load the PHP drivers when PHP starts.
If you installed PHP from package, the output will be slightly different and will probably list more .ini files, but you will likely need to edit only the `php.ini` file listed under `Loaded Configuration File`.
2. If `Loaded Configuration File` shows that a `php.ini` is loaded, edit that file. Otherwise go to the PHP directory in your home directory, run `cp php.ini-development php.ini` and copy the newly created `php.ini` file to the `Configuration File (php.ini) Path` indicated when running `php --ini`. If using the SQLSRV driver, add the following lines to your php.ini: `extension=php_sqlsrv_7_ts.so` or `extension=php_sqlsrv_7_nts.so` If using the PDO_SQLSRV driver, add `extension=php_pdo_sqlsrv_7_ts.so` or `extension=php_pdo_sqlsrv_7_nts.so`. If necessary, specify the extension directory using extension_dir, for example: `extension_dir = “/usr/local/lib/php/extensions/”`. To find the default extension directory, run `php -i | grep extension_dir`.
2. If `Loaded Configuration File` shows that a `php.ini` is loaded, edit that file. Otherwise go to the PHP directory in your home directory, run `cp php.ini-development php.ini` and copy the newly created `php.ini` file to the `Configuration File (php.ini) Path` indicated when running `php --ini`. If using the SQLSRV driver, add the following lines to your php.ini: `extension=php_sqlsrv_7_ts.so` or `extension=php_sqlsrv_7_nts.so` If using the PDO_SQLSRV driver, add `extension=php_pdo_sqlsrv_7_ts.so` or `extension=php_pdo_sqlsrv_7_nts.so`. Change the names of the drivers accordingly if you have compiled them from source and they have different names. If necessary, specify the extension directory using extension_dir, for example: `extension_dir = “/usr/local/lib/php/extensions/”`. To find the default extension directory, run `php -i | grep extension_dir`.
3. Stop and restart the Apache web server.
@ -186,10 +189,12 @@ Now edit your `php.ini` file to load the PHP drivers when PHP starts.
If you do not see sections on sqlsrv and pdo_sqlsrv extensions, these extensions are not loaded. Near the top of the PHP info page, check which `php.ini` is loaded. This may be different from the `php.ini` file loaded when running php from the command line, especially if Apache and PHP were installed from your package manager. In this case, edit the `php.ini` displayed on the PHP info page to load the extensions in the same way described above. Restart the Apache web server and verify that phpinfo() loads the sqlsrv extensions.
####Links:
Microsoft PHP GitHub repository https://github.com/Azure/msphpsql
UnixODBC 2.3.1 for Ubuntu. [http://www.unixodbc.org/pub/unixODBC/unixODBC-2.3.1.tar.gz](http://www.unixodbc.org/pub/unixODBC/unixODBC-2.3.1.tar.gz)
Microsoft® ODBC Driver 13 (Preview) for SQL Server® - Ubuntu Linux [https://www.microsoft.com/en-us/download/details.aspx?id=50419](https://www.microsoft.com/en-us/download/details.aspx?id=50419)
Microsoft® ODBC Driver 13 (Preview) and 11 for SQL Server® - Red Hat Linux [https://www.microsoft.com/en-us/download/details.aspx?id=36437](https://www.microsoft.com/en-us/download/details.aspx?id=36437)
Microsoft PHP GitHub repository: https://github.com/Azure/msphpsql
UnixODBC 2.3.1 for Ubuntu: [http://www.unixodbc.org/pub/unixODBC/unixODBC-2.3.1.tar.gz](http://www.unixodbc.org/pub/unixODBC/unixODBC-2.3.1.tar.gz)
Microsoft® ODBC Driver 13 (Preview) for SQL Server® - Ubuntu Linux: [https://www.microsoft.com/en-us/download/details.aspx?id=50419](https://www.microsoft.com/en-us/download/details.aspx?id=50419)
Microsoft® ODBC Driver 13 (Preview) and 11 for SQL Server® - Red Hat Linux: [https://www.microsoft.com/en-us/download/details.aspx?id=36437](https://www.microsoft.com/en-us/download/details.aspx?id=36437)
Apache source: [http://httpd.apache.org/download.cgi#apache24](http://httpd.apache.org/download.cgi)
Apache Portable Runtime (APR): [http://apr.apache.org/download.cgi](http://apr.apache.org/download.cgi)
PHP source download page: [http://php.net/downloads.php](http://php.net/downloads.php)
PHP source download page: [http://php.net/downloads.php](http://php.net/downloads.php)
Ondrej PPA repository: [https://launchpad.net/~ondrej/+archive/ubuntu/php](https://launchpad.net/~ondrej/+archive/ubuntu/php)
Remi RPM repository: [http://blog.remirepo.net/post/2016/02/14/Install-PHP-7-on-CentOS-RHEL-Fedora](http://blog.remirepo.net/post/2016/02/14/Install-PHP-7-on-CentOS-RHEL-Fedora)

View file

@ -10,7 +10,31 @@ SQL Server Team
##Announcements
August 23, 2016 (4.0.3): Linux drivers built with PHP 7.0.9 are available for Ubuntu 15.04, Ubuntu 16.04, and RedHat 7.2. The source code of the drivers has also been made available, we recommend building drivers from source using the tutorial [here](https://github.com/Azure/msphpsql/blob/PHP-7.0-Linux/LinuxTutorial.md). This release includes following bug fixes:
**September 9, 2016**: Linux drivers (4.0.4) compiled with PHP 7.0.10 are available for Ubuntu 15.04, Ubuntu 16.04, and RedHat 7.2. This release includes the following fixes:
- Fixed undefined symbols at SQL* error when loading the drivers.
- Fixed undefined symbol issues at LocalAlloc and LocalFree on RedHat7.2.
- Fixed [issue #144](https://github.com/Microsoft/msphpsql/issues/144) (floating point exception).
- Fixed [issue #119](https://github.com/Microsoft/msphpsql/issues/119) (modifying class name in sqlsrv_fetch_object).
- Added Support for EMULATE_PREPARE feature.
- Added following integer SQL Types constants for cases which function-like SQL types constants cannot be used e.g. type comparison:
SQLSRV constant | Typical SQL Server data type | SQL type identifier
------------ | ----------------------- | ----------------------
SQLSRV_SQLTYPE_DECIMAL | decimal | SQL_DECIMAL
SQLSRV_SQLTYPE_NUMERIC | numeric | SQL_NUMERIC
SQLSRV_SQLTYPE_CHAR | char | SQL_CHAR
SQLSRV_SQLTYPE_NCHAR | nchar | SQL_WCHAR
SQLSRV_SQLTYPE_VARCHAR | varchar | SQL_VARCHAR
SQLSRV_SQLTYPE_NVARCHAR | nvarchar | SQL_WVARCHAR
SQLSRV_SQLTYPE_BINARY | binary | SQL_BINARY
SQLSRV_SQLTYPE_VARBINARY | varbinary | SQL_VARBINARY
Note: These constants should be used in type comparison operations (refer to issue [#87](https://github.com/Microsoft/msphpsql/issues/87) and [#99](https://github.com/Microsoft/msphpsql/issues/99) ), and don't replace the function like constants with similar syntax. For binding parameters you should use the function-like constants, otherwise you'll get an error.
**August 23, 2016** : Linux drivers (4.0.3) compiled with PHP 7.0.9 are available for Ubuntu 15.04, Ubuntu 16.04, and RedHat 7.2. The source code of the drivers has also been made available, we recommend building drivers from source using the tutorial [here](https://github.com/Azure/msphpsql/blob/PHP-7.0-Linux/LinuxTutorial.md). This release includes following bug fixes:
- Fixed data corruption in binding integer parameters.
- Fixed invalid sql_display_size error.
@ -18,7 +42,7 @@ August 23, 2016 (4.0.3): Linux drivers built with PHP 7.0.9 are available for Ub
- Fixed binding bit parameters.
July 29, 2016 (4.0.2): Updated Linux drivers are available for Ubuntu 15.04, Ubuntu 16.04, and RedHat 7.2. This update provides the following improvements and bug fixes:
**July 29, 2016**: Updated Linux drivers (4.0.2) are available for Ubuntu 15.04, Ubuntu 16.04, and RedHat 7.2. This update provides the following improvements and bug fixes:
- The PDO_SQLSRV driver no longer requires PDO to be built as a shared extension.
- Fixed an issue with format specifiers in error messages.
@ -26,7 +50,7 @@ July 29, 2016 (4.0.2): Updated Linux drivers are available for Ubuntu 15.04, Ubu
- Fixed an issue whereby calling sqlsrv_rows_affected on an empty result set would return a null result instead of 0.
- Fixed an issue with error messages when there is an error in sizes in SQLSRV_SQLTYPE_*.
July 11, 2016 (4.0.1): Thread safe and non-thread safe variations for SQLSRV and PDO_SQLSRV for Linux drivers with basic functionalities are now available. The drivers have been built and tested on Ubuntu 15.04, Ubuntu 16.04, and RedHat 7.2.. Also, there are some improvements on the drivers that we would like to share:
**July 11, 2016**: Thread safe and non-thread safe variations for SQLSRV and PDO_SQLSRV for Linux drivers (4.0.1) with basic functionalities are now available. The drivers have been built and tested on Ubuntu 15.04, Ubuntu 16.04, and RedHat 7.2.. Also, there are some improvements on the drivers that we would like to share:
- Improved handling varchar(MAX).
- Improved handling basic stream operations.
@ -43,10 +67,12 @@ June 20, 2016 (4.0.0): The early technical preview (ETP) for SQLSRV and PDO_SQLS
## Install
For detailed instructions please review the tutorial [here](https://github.com/Azure/msphpsql/blob/PHP-7.0-Linux/LinuxTutorial.md).
The drivers are distributed as shared binary extensions for PHP. They are available in thread safe (*_ts.so) and-non thread safe (*_nts.so) versions. The source code for the drivers is also available, and you can choose whether to compile them as thread safe or non-thread safe versions. The thread safety configuration of your web server will determine which version you need. If you wish to install Apache from source, follow these instructions:
1. Download the source from [Apache.org][httpd_source]. Unzip the source to a local directory.
2. Download the [Apache Portable Runtime (APR) and Utility][apr_source]. Unzip the APR source into srclib/apr and the APR-Util source into srclib/apr-util in your Apache directory from Step 1.
3. If you have the thread safe binaries, run `./configure --enable-so --with-mpm=worker`. If you have the non-thread safe binaries, run `./configure --enable-so --with-mpm=prefork`.
@ -59,26 +85,24 @@ Now you are ready to install PHP.
- Method 1: Using your package manager:
Make sure the packaged PHP version is PHP 7. *Note*: We do not recommend this method, as php-odbc may introduce conflicts with the unixODBC driver manager that you have already installed.
Make sure the packaged PHP version is PHP 7. You may need to add repositories to obtain PHP 7 as described in the [tutorial]((https://github.com/Azure/msphpsql/blob/PHP-7.0-Linux/LinuxTutorial.md)).
1. Use your package manager to install php and php-odbc.
1. Use your package manager to install the php package.
2. Copy the precompiled binaries into the extensions directory (likely in /usr/lib/php).
3. Edit the php.ini file as indicated in "Enable the drivers" section.
3. Edit the php.ini file as indicated in the "Enable the drivers" section.
- Method 2: Using the PHP source:
Download the PHP 7 source and unzip it to a local directory. Then follow the steps below:
1. Switch to the PHP directory and run `./buildconf --force`. You may need to install autoconf with your package-manager prior to this step.
1. Switch to the PHP directory and run `./buildconf --force`. You may need to install autoconf with your package manager prior to this step.
2. Run `./configure` with the following options on the command line:
(i) `LIBS=-lodbc`
(ii) the path for the unixODBC header files using `--with-unixODBC=<path-to-ODBC-headers>`. To find the path for the header files, use the command `sudo find / -name sql.h`. Then add this path, without the /include/sql.h, to the command line. For example, if the find command yields /usr/include/sql.h, add `--with-unixODBC=/usr` to the `./configure` command line.
(iii) the path to apxs or apxs2 to configure PHP for Apache using `--with-apxs2=<path-to-apxs>`. To find the path to apxs (or apxs2), run `sudo find / -name apxs` (or `sudo find / -name apxs2`) and add the resulting path to the option.
(iv) if your web server has thread safety enabled, a thread-safe build of PHP. Add `--enable-maintainer-zts` to `./configure`.
(i) the path to apxs or apxs2 to configure PHP for Apache using `--with-apxs2=<path-to-apxs>`. To find the path to apxs (or apxs2), run `sudo find / -name apxs` (or `sudo find / -name apxs2`) and add the resulting path to the option. For example, if the find command yields `/usr/bin/apxs2`, add `--with-apxs2=/usr/bin/apxs2` to the `./configure` command line.
(ii) if your web server has thread safety enabled, specify a thread-safe build of PHP. Add `--enable-maintainer-zts` to `./configure`.
Thus your `./configure` command should look like `./configure LIBS=-lodbc --with-unixODBC=<path-to-ODBC-headers> --with-apxs2=<path-to-apxs-executable> --enable-maintainer-zts`.
Thus your `./configure` command should look like `./configure --with-apxs2=<path-to-apxs-executable> --enable-maintainer-zts`.
If your `./configure` command exits with an error saying it cannot find xml2-config, you may need to install libxml2-dev using your package manager before continuing.
@ -95,13 +119,12 @@ Now you are ready to install PHP.
2. Run `./configure` with the same options listed above, in addition to the following:
(i) `CXXFLAGS=-std=c++11` to ensure your compiler uses the C++11 standard.
(ii) `--enable-sqlsrv=shared `
(iii)`--with-pdo_sqlsrv=shared`
(iv)`--with-odbcver=0x0380`. This option has no practical effect as the drivers use ODBC version 3.52, but it suppresses compilation warnings arising from the fact that PHP's default setting of version 3.00 is different from unixODBC's setting of 3.80.
(ii) `--enable-sqlsrv=shared `
(iii)`--with-pdo_sqlsrv=shared`
(iv)`--with-odbcver=0x0380`. This option has no practical effect as the drivers use ODBC version 3.52, but it suppresses compilation warnings arising from the fact that PHP's default setting of version 3.00 is different from unixODBC's setting of 3.80.
Thus your `./configure` command should look like `./configure LIBS=-lodbc --with-unixODBC=<path-to-ODBC-headers> --with-apxs2=<path-to-apxs-executable> CXXFLAGS=-std=c++11 --enable-sqlsrv=shared --with-pdo_sqlsrv=shared --with-odbcver=0x0380`.
Thus your `./configure` command should look like `./configure --with-apxs2=<path-to-apxs-executable> CXXFLAGS=-std=c++11 --enable-sqlsrv=shared --with-pdo_sqlsrv=shared --with-odbcver=0x0380`.
3. Run `make`. The compiled drivers will be located in the `modules/` directory, and are named `sqlsrv.so` and `pdo_sqlsrv.so`.
4. Run `sudo make install` to install the binaries into the default php extensions directory.
@ -132,12 +155,12 @@ For samples, please see the sample folder. For setup instructions, see [here] [
## Limitations
- This preview contains the PHP 7 port of the SQLSRV and PDO_SQLSRV drivers, and does not provide backwards compatibility with PHP 5.
- Binding output parameter using emulate prepare is not supported.
- ODBC 3.52 is supported but not 3.8.
##Known issues
The following items have known issues:
- There are issues with loading the drivers, we recommend building drivers from source for all variations until we fix the issue.
- Retrieving, inserting, and binding Char, Varchar datatypes.
- Logging.
- Local encodings other than UTF-8 are not supported for output.
@ -146,7 +169,8 @@ The following items have known issues:
- Fetch object and fetch array have issues.
- lastInsertId().
- Query from large column name.
- ODBC 3.52 is supported but not 3.8.
- Binary column binding with emulate prepare ([issue#140](https://github.com/Microsoft/msphpsql/issues/140) )
## Guidelines for Reporting Issues
@ -224,4 +248,4 @@ This project has adopted the Microsoft Open Source Code of Conduct. For more inf
[apr_source]: http://apr.apache.org/
[httpdconf]: http://php.net/manual/en/install.unix.apache2.php
[httpdconf]: http://php.net/manual/en/install.unix.apache2.php

Binary file not shown.

Binary file not shown.

View file

@ -1,4 +0,0 @@
51277515e835f6f25ba9522f7957e2d048e475eba58195abe585cabdd6e53cdf php_sqlsrv_7_nts.so
d3a96ebcfa84be30ac84363671554082f0aed13c3966953601506eb80b6fd2a2 php_pdo_sqlsrv_7_nts.so
6a70f314bb8ed6f5d35a27b0c2689994abb23e83afacced0ebb2d54809f13ffe php_sqlsrv_7_ts.so
31ddbb66a8af1f1a60949de26925fe9bfe6cc2dce9b4ecbcf512ef827c58c71d php_pdo_sqlsrv_7_ts.so

Binary file not shown.

View file

@ -1,4 +0,0 @@
ea45bde611ef32835c7972ba86ce513bc96ace8a6b2d5d251a9bde54f489cea4 php_sqlsrv_7_nts.so
83913649396d4d8dfc07798dd08c28545bb63fde073ffd3f8fac8e22f44d8011 php_pdo_sqlsrv_7_nts.so
a1a40b11073f7e648f694151a8dd5490c7f9412faca5fbded05dd14641b76ed2 php_sqlsrv_7_ts.so
36096cf816a5ab653e53c9f060df301f59dc7dd0ed570dbc779f6fbda0758cbc php_pdo_sqlsrv_7_ts.so

Binary file not shown.

View file

@ -1,4 +0,0 @@
ed3adea0a6f21c59e4f9b2c4d2465513c1182d8baaabfd322c0f7c67b0a52d8c php_sqlsrv_7_nts.so
fce3b69fc2edeac62984bdcf30327fe9809a210e0f06bb804ffb19dc5de169d4 php_pdo_sqlsrv_7_nts.so
1fb8c4f838d9165290218f12b0632e5a0dcf8327f821013140dfd909dd0964df php_sqlsrv_7_ts.so
ce7e77cc18da4d60125158e13360c7bad0373bcbdc0d85937e79ed2e2829f4c7 php_pdo_sqlsrv_7_ts.so

View file

@ -10,7 +10,7 @@
// Comments:
//
// owners:
// See source code ownership database in SqlDevDash
// See source code ownership database in SqlDevDash
//-----------------------------------------------------------------------------
#include <FormattedPrint.h>
@ -38,9 +38,9 @@
#ifdef __linux__
#define PTR_IS_INT64 1
#else
#else
#define PTR_IS_INT64 0
#endif
#endif
#ifndef _MSC_VER
// SQL Server does not have a long double type
@ -259,7 +259,7 @@ errno_t mplat_wctomb_s(
int *pRetValue,
char *mbchar,
size_t sizeInBytes,
WCHAR wchar
WCHAR wchar
)
{
DWORD rc;
@ -393,7 +393,7 @@ static enum STATE ProcessSizeA( char sizeCh, char fmt_ch, char next_fmt_ch, int
case 'w':
*flags |= FL_WIDECHAR;
}
return ST_SIZE;
}
@ -465,7 +465,7 @@ static enum STATE ProcessSizeW( WCHAR sizeCh, WCHAR fmt_ch, WCHAR next_fmt_ch, i
case L'w':
*flags |= FL_WIDECHAR;
}
return ST_SIZE;
}
@ -2590,7 +2590,7 @@ DWORD FormatMessageA(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD d
DWORD FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, va_list *Arguments)
{
DWORD chars_printed = 0;
// XPLAT_ODBC_TODO VSTS 718708 Localization by handling FORMAT_MESSAGE_FROM_HMODULE and dwLanguageId param
if ( dwFlags & FORMAT_MESSAGE_FROM_STRING )
{
@ -2679,8 +2679,6 @@ DWORD FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD d
}
//--------Other definitions from xplat stub sources--------------
// void SSetLastError(DWORD err) { errno = err; }
// unsigned int GGetLastError() { return errno; }
BOOL IsDBCSLeadByte(__inn BYTE TestChar)
{
@ -2776,9 +2774,23 @@ char * mplat_cscpy( char * dst, const char * src )
size_t mplat_wcslenn( const WCHAR * str )
{
const WCHAR * eos = str;
while( *eos++ )
const WCHAR * eos = str;
while( *eos++ )
{
}
return( (size_t)(eos - str- 1) );
return( (size_t)(eos - str- 1) );
}
HLOCAL LocalAlloc(UINT uFlags, SIZE_T uBytes)
{
assert(uFlags == 0); // For now
return malloc(uBytes);
}
HLOCAL LocalFree(HLOCAL hMem)
{
assert(hMem != NULL);
free(hMem);
return NULL;
}

View file

@ -44,7 +44,7 @@ if test "$PHP_PDO_SQLSRV" != "no"; then
PHP_ADD_LIBRARY(stdc++, 1, PDO_SQLSRV_SHARED_LIBADD)
PHP_ADD_LIBRARY(odbc, 1, PDO_SQLSRV_SHARED_LIBADD)
AC_DEFINE(HAVE_PDO_SQLSRV, 1, [ ])
PHP_NEW_EXTENSION(pdo_sqlsrv, $sources, $ext_shared,,-I$pdo_cv_inc_path -std=c++11)
PHP_NEW_EXTENSION(pdo_sqlsrv, $sources, $ext_shared,,-I$pdo_cv_inc_path, -std=c++11)
PHP_SUBST(PDO_SQLSRV_SHARED_LIBADD)
PHP_ADD_EXTENSION_DEP(pdo_sqlsrv, pdo)
fi

View file

@ -1954,7 +1954,7 @@ void default_sql_size_and_scale( sqlsrv_stmt* stmt, unsigned int paramno, zval*
break;
case IS_STRING:
{
size_t char_size = Z_STRLEN_P( param_z ) * ((encoding == SQLSRV_ENCODING_UTF8 ) ? sizeof( SQLWCHAR ) : sizeof( char ));
size_t char_size = (encoding == SQLSRV_ENCODING_UTF8 ) ? sizeof( SQLWCHAR ) : sizeof( char );
SQLULEN byte_len = Z_STRLEN_P(param_z) * char_size;
if( byte_len > SQL_SERVER_MAX_FIELD_SIZE ) {
column_size = SQL_SERVER_MAX_TYPE_SIZE;

View file

@ -380,7 +380,8 @@ pdo_sqlsrv_dbh::pdo_sqlsrv_dbh( SQLHANDLE h, error_callback e, void* driver TSRM
stmts( NULL ),
direct_query( false ),
query_timeout( QUERY_TIMEOUT_INVALID ),
client_buffer_max_size( PDO_SQLSRV_G( client_buffer_max_size ) )
client_buffer_max_size( PDO_SQLSRV_G( client_buffer_max_size ) ),
bind_param_encoding(SQLSRV_ENCODING_CHAR)
{
if( client_buffer_max_size < 0 ) {
client_buffer_max_size = sqlsrv_buffered_result_set::BUFFERED_QUERY_LIMIT_DEFAULT;
@ -1215,37 +1216,77 @@ int pdo_sqlsrv_dbh_quote( pdo_dbh_t* dbh, const char* unquoted, size_t unquoted_
PDO_VALIDATE_CONN;
PDO_LOG_DBH_ENTRY;
// count the number of quotes needed
unsigned int quotes_needed = 2; // the initial start and end quotes of course
for(size_t index = 0; index < unquoted_len && unquoted[ index ] != '\0'; ++index ) {
if( unquoted[ index ] == '\'' ) {
++quotes_needed;
}
}
pdo_sqlsrv_dbh* driver_dbh = reinterpret_cast<pdo_sqlsrv_dbh*>( dbh->driver_data );
SQLSRV_ENCODING encoding = driver_dbh->bind_param_encoding;
*quoted_len = unquoted_len + quotes_needed; // length returned to the caller should not account for null terminator.
*quoted = reinterpret_cast<char*>( sqlsrv_malloc( *quoted_len, sizeof( char ), 1 )); // include space for null terminator.
unsigned int out_current = 0;
if ( encoding == SQLSRV_ENCODING_BINARY ) {
// convert from char* to hex digits using os
std::basic_ostringstream<char> os;
for ( size_t index = 0; index < unquoted_len && unquoted[ index ] != '\0'; ++index ) {
os << std::hex << ( int )unquoted[ index ];
}
std::basic_string<char> str_hex = os.str();
// each character is represented by 2 digits of hex
size_t unquoted_str_len = unquoted_len * 2; // length returned should not account for null terminator
char* unquoted_str = reinterpret_cast<char*>( sqlsrv_malloc( unquoted_str_len, sizeof( char ), 1 )); // include space for null terminator
strcpy_s( unquoted_str, unquoted_str_len + 1 /* include null terminator*/, str_hex.c_str() );
// include length of '0x' in the binary string
*quoted_len = unquoted_str_len + 2;
*quoted = reinterpret_cast<char*>( sqlsrv_malloc( *quoted_len, sizeof( char ), 1 ));
unsigned int out_current = 0;
// insert '0x'
( *quoted )[ out_current++ ] = '0';
( *quoted )[ out_current++ ] = 'x';
for ( size_t index = 0; index < unquoted_str_len && unquoted_str[ index ] != '\0'; ++index ) {
( *quoted )[ out_current++ ] = unquoted_str[ index ];
}
// null terminator
( *quoted )[ out_current ] = '\0';
sqlsrv_free( unquoted_str );
return 1;
}
else {
// count the number of quotes needed
unsigned int quotes_needed = 2; // the initial start and end quotes of course
// include the N proceeding the initial quote if encoding is UTF8
if ( encoding == SQLSRV_ENCODING_UTF8 ) {
quotes_needed = 3;
}
for ( size_t index = 0; index < unquoted_len && unquoted[ index ] != '\0'; ++index ) {
if ( unquoted[ index ] == '\'' ) {
++quotes_needed;
}
}
// insert initial quote
(*quoted)[ out_current++ ] ='\'';
*quoted_len = unquoted_len + quotes_needed; // length returned to the caller should not account for null terminator.
*quoted = reinterpret_cast<char*>( sqlsrv_malloc( *quoted_len, sizeof( char ), 1 )); // include space for null terminator.
unsigned int out_current = 0;
for(size_t index = 0; index < unquoted_len && unquoted[ index ] != '\0'; ++index ) {
// insert N if the encoding is UTF8
if ( encoding == SQLSRV_ENCODING_UTF8 ) {
( *quoted )[ out_current++ ] = 'N';
}
if( unquoted[ index ] == '\'' ) {
(*quoted)[ out_current++ ] = '\'';
(*quoted)[ out_current++ ] = '\'';
}
else {
(*quoted)[ out_current++ ] = unquoted[ index ];
}
}
// insert initial quote
( *quoted )[ out_current++ ] = '\'';
// trailing quote and null terminator
(*quoted)[ out_current++ ] ='\'';
(*quoted)[ out_current ] = '\0';
for ( size_t index = 0; index < unquoted_len && unquoted[ index ] != '\0'; ++index ) {
return 1;
if ( unquoted[ index ] == '\'' ) {
( *quoted )[ out_current++ ] = '\'';
( *quoted )[ out_current++ ] = '\'';
}
else {
( *quoted )[ out_current++ ] = unquoted[ index ];
}
}
// trailing quote and null terminator
( *quoted )[ out_current++ ] = '\'';
( *quoted )[ out_current ] = '\0';
return 1;
}
}
// This method is not implemented by this driver.

View file

@ -180,6 +180,7 @@ struct pdo_sqlsrv_dbh : public sqlsrv_conn {
bool direct_query;
long query_timeout;
zend_long client_buffer_max_size;
SQLSRV_ENCODING bind_param_encoding;
pdo_sqlsrv_dbh( SQLHANDLE h, error_callback e, void* driver TSRMLS_DC );
};

View file

@ -1085,7 +1085,12 @@ int pdo_sqlsrv_stmt_param_hook(pdo_stmt_t *stmt,
// since the param isn't reliable, we don't do anything here
case PDO_PARAM_EVT_ALLOC:
break;
// if emulate prepare is on, set the bind_param_encoding so it can be used in PDO::quote when binding parameters on the client side
if ( stmt->supports_placeholders == PDO_PLACEHOLDER_NONE ) {
pdo_sqlsrv_dbh* driver_dbh = reinterpret_cast<pdo_sqlsrv_dbh*>( stmt->dbh->driver_data );
driver_dbh->bind_param_encoding = static_cast<SQLSRV_ENCODING>( Z_LVAL( param->driver_params ));
}
break;
case PDO_PARAM_EVT_FREE:
break;
// bind the parameter in the core layer

View file

@ -16,11 +16,11 @@
// IN THE SOFTWARE.
//---------------------------------------------------------------------------------------------------------------------------------
#define VER_FILEVERSION_STR "4.0.3.0"
#define _FILEVERSION 4,0,3,0
#define VER_FILEVERSION_STR "4.0.0.0"
#define _FILEVERSION 4,0,0,0
#define SQLVERSION_MAJOR 4
#define SQLVERSION_MINOR 0
#define SQLVERSION_MMDD 3
#define SQLVERSION_MMDD 0
#define SQLVERSION_REVISION 0

View file

@ -10,7 +10,7 @@
// Comments:
//
// owners:
// See source code ownership database in SqlDevDash
// See source code ownership database in SqlDevDash
//-----------------------------------------------------------------------------
#include <FormattedPrint.h>
@ -38,9 +38,9 @@
#ifdef __linux__
#define PTR_IS_INT64 1
#else
#else
#define PTR_IS_INT64 0
#endif
#endif
#ifndef _MSC_VER
// SQL Server does not have a long double type
@ -259,7 +259,7 @@ errno_t mplat_wctomb_s(
int *pRetValue,
char *mbchar,
size_t sizeInBytes,
WCHAR wchar
WCHAR wchar
)
{
DWORD rc;
@ -393,7 +393,7 @@ static enum STATE ProcessSizeA( char sizeCh, char fmt_ch, char next_fmt_ch, int
case 'w':
*flags |= FL_WIDECHAR;
}
return ST_SIZE;
}
@ -465,7 +465,7 @@ static enum STATE ProcessSizeW( WCHAR sizeCh, WCHAR fmt_ch, WCHAR next_fmt_ch, i
case L'w':
*flags |= FL_WIDECHAR;
}
return ST_SIZE;
}
@ -2590,7 +2590,7 @@ DWORD FormatMessageA(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD d
DWORD FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, va_list *Arguments)
{
DWORD chars_printed = 0;
// XPLAT_ODBC_TODO VSTS 718708 Localization by handling FORMAT_MESSAGE_FROM_HMODULE and dwLanguageId param
if ( dwFlags & FORMAT_MESSAGE_FROM_STRING )
{
@ -2679,8 +2679,6 @@ DWORD FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD d
}
//--------Other definitions from xplat stub sources--------------
// void SSetLastError(DWORD err) { errno = err; }
// unsigned int GGetLastError() { return errno; }
BOOL IsDBCSLeadByte(__inn BYTE TestChar)
{
@ -2776,9 +2774,23 @@ char * mplat_cscpy( char * dst, const char * src )
size_t mplat_wcslenn( const WCHAR * str )
{
const WCHAR * eos = str;
while( *eos++ )
const WCHAR * eos = str;
while( *eos++ )
{
}
return( (size_t)(eos - str- 1) );
return( (size_t)(eos - str- 1) );
}
HLOCAL LocalAlloc(UINT uFlags, SIZE_T uBytes)
{
assert(uFlags == 0); // For now
return malloc(uBytes);
}
HLOCAL LocalFree(HLOCAL hMem)
{
assert(hMem != NULL);
free(hMem);
return NULL;
}

View file

@ -1,16 +1,14 @@
dnl
dnl $Id$
dnl
PHP_ARG_ENABLE(sqlsrv, whether to enable sqlsrv functions,
[ --disable-sqlsrv Disable sqlsrv functions], yes)
if test "$PHP_SQLSRV" != "no"; then
PHP_REQUIRE_CXX()
PHP_SUBST(SQLSRV_SHARED_LIBADD)
PHP_ADD_LIBRARY(stdc++, 1, SQLSRV_SHARED_LIBADD)
PHP_ADD_LIBRARY(odbc, 1, SQLSRV_SHARED_LIBADD)
PHP_SUBST(SQLSRV_SHARED_LIBADD)
AC_DEFINE(HAVE_SQLSRV, 1, [ ])
PHP_NEW_EXTENSION(sqlsrv, conn.cpp stmt.cpp init.cpp util.cpp \
core_init.cpp core_conn.cpp core_stmt.cpp \
core_util.cpp core_stream.cpp core_results.cpp \

View file

@ -1954,7 +1954,7 @@ void default_sql_size_and_scale( sqlsrv_stmt* stmt, unsigned int paramno, zval*
break;
case IS_STRING:
{
size_t char_size = Z_STRLEN_P( param_z ) * ((encoding == SQLSRV_ENCODING_UTF8 ) ? sizeof( SQLWCHAR ) : sizeof( char ));
size_t char_size = (encoding == SQLSRV_ENCODING_UTF8 ) ? sizeof( SQLWCHAR ) : sizeof( char );
SQLULEN byte_len = Z_STRLEN_P(param_z) * char_size;
if( byte_len > SQL_SERVER_MAX_FIELD_SIZE ) {
column_size = SQL_SERVER_MAX_TYPE_SIZE;

View file

@ -388,6 +388,17 @@ PHP_MINIT_FUNCTION(sqlsrv)
constant_type.typeinfo.scale = 7;
REGISTER_LONG_CONSTANT( "SQLSRV_SQLTYPE_DATETIME2", constant_type.value, CONST_PERSISTENT | CONST_CS );
// These constant are defined to provide type checking (type ==SQLSRV_SQLTYPE_DECIMAL).
// There are functions with the same name which accept parameters and is used in binding paramters.
REGISTER_LONG_CONSTANT("SQLSRV_SQLTYPE_DECIMAL", SQL_DECIMAL, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQLSRV_SQLTYPE_NUMERIC", SQL_NUMERIC, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQLSRV_SQLTYPE_CHAR", SQL_CHAR, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQLSRV_SQLTYPE_NCHAR", SQL_WCHAR, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQLSRV_SQLTYPE_VARCHAR", SQL_VARCHAR, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQLSRV_SQLTYPE_NVARCHAR", SQL_WVARCHAR, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQLSRV_SQLTYPE_BINARY", SQL_BINARY, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("SQLSRV_SQLTYPE_VARBINARY", SQL_VARBINARY, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT( "SQLSRV_PARAM_IN", SQL_PARAM_INPUT, CONST_PERSISTENT | CONST_CS );
REGISTER_LONG_CONSTANT( "SQLSRV_PARAM_OUT", SQL_PARAM_OUTPUT, CONST_PERSISTENT | CONST_CS );
REGISTER_LONG_CONSTANT( "SQLSRV_PARAM_INOUT", SQL_PARAM_INPUT_OUTPUT, CONST_PERSISTENT | CONST_CS );

View file

@ -796,6 +796,7 @@ PHP_FUNCTION( sqlsrv_fetch_object )
}
class_name = Z_STRVAL( *class_name_z );
class_name_len = Z_STRLEN( *class_name_z );
//zend_str_tolower( class_name, class_name_len );
}
if( ctor_params_z && Z_TYPE_P( ctor_params_z ) != IS_ARRAY ) {

View file

@ -16,11 +16,11 @@
// IN THE SOFTWARE.
//---------------------------------------------------------------------------------------------------------------------------------
#define VER_FILEVERSION_STR "4.0.3.0"
#define _FILEVERSION 4,0,3,0
#define VER_FILEVERSION_STR "4.0.0.0"
#define _FILEVERSION 4,0,0,0
#define SQLVERSION_MAJOR 4
#define SQLVERSION_MINOR 0
#define SQLVERSION_MMDD 3
#define SQLVERSION_MMDD 0
#define SQLVERSION_REVISION 0