4.0.3 Release

This commit is contained in:
Meet Bhagdev 2016-08-24 14:46:45 -07:00
parent 586b697ce7
commit 770f5dab81
27 changed files with 398 additions and 127 deletions

View file

@ -1,155 +1,181 @@
#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 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.
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.
###Install the unixODBC driver manager and Microsoft ODBC driver for Linux
You can install both the unixODBC driver manager and the ODBC driver using the shell script found on GitHub.
Be sure to use the shell script appropriate for your Linux distribution. We do not recommend installing unixODBC
from your package manager.
You can install both the unixODBC driver manager and the ODBC driver using the shell script found on GitHub. Be sure to use the shell script appropriate for your Linux distribution. We do not recommend installing unixODBC from your package manager.
1. Download the shell script from the PHP Linux [GitHub repository](https://github.com/Azure/msphpsql/tree/PHP-7.0-Linux/ODBC%20install%20scripts) and install them.
* For Ubuntu 15.04 amd 16.04, run:
`sudo su`
`wget https://raw.githubusercontent.com/Azure/msphpsql/PHP-7.0-Linux/ODBC%20install%20scripts/installodbc_ubuntu.sh`
`sh installodbc_ubuntu.sh`
* For RedHat 7.2 or CentOS 7.2, run:
`sudo su`
`wget https://raw.githubusercontent.com/Azure/msphpsql/PHP-7.0-Linux/ODBC%20install%20scripts/installodbc_redhat.sh`
`sh installodbc_redhat.sh`
2. Verify that the ODBC driver on Linux is registered successfully by executing the following commands:
* For Ubuntu 15.04 amd 16.04
```sudo su ```
<br>```wget https://raw.githubusercontent.com/Azure/msphpsql/PHP-7.0-Linux/ODBC%20install%20scripts/installodbc_ubuntu.sh ```
<br>```sh installodbc_ubuntu.sh ```
* For RedHat 7.2 or CentOS 7.2
```sudo su ```
<br>```wget https://raw.githubusercontent.com/Azure/msphpsql/PHP-7.0-Linux/ODBC%20install%20scripts/installodbc_redhat.sh ```
<br>```sh installodbc_redhat.sh```
* Verify that the ODBC driver on Linux is registered successfully by executing the following commands:
```odbcinst j` `odbcinst -q -d -n "ODBC Driver 13 for SQL Server" ```
`odbcinst j`
`odbcinst -q -d -n "ODBC Driver 13 for SQL Server"`
You should see output similar to the following:
You should see output similar to the following:
[![pic1](https://msdnshared.blob.core.windows.net/media/2016/07/image1101.png)](https://msdnshared.blob.core.windows.net/media/2016/07/image1101.png)
###Install Apache: You are now ready to install Apache. You can install from source, or you can use your package manager. ###
To install from source, follow these instructions.
1. From the Apache web site, download the Apache source. Go to [http://httpd.apache.org/download.cgi#apache24](http://httpd.apache.org/download.cgi) and click on the link to the tar.gz file. In what follows, we'll assume it is httpd-2.4.20.tar.gz. Take note of the directory to which it is downloaded.
1. From the Apache web site, download the Apache source. Go to [http://httpd.apache.org/download.cgi#apache24](http://httpd.apache.org/download.cgi) and click on the link to the tar.gz file. In what follows, we'll assume it is `httpd-2.4.20.tar.gz`. Take note of the directory to which it is downloaded.
[![pic2](https://msdnshared.blob.core.windows.net/media/2016/07/image2100.png)](https://msdnshared.blob.core.windows.net/media/2016/07/image2100.png)
2. Download the Apache Portable Runtime (APR) and APR utilities from [http://apr.apache.org/download.cgi](http://apr.apache.org/download.cgi). Click on apr-1.5.2.tar.gz and apr-util-1.5.4.tar.gz to download.
2. Download the Apache Portable Runtime (APR) and APR utilities from [http://apr.apache.org/download.cgi](http://apr.apache.org/download.cgi). Click on `apr-1.5.2.tar.gz` and `apr-util-1.5.4.tar.gz` to download.
[![pic3](https://msdnshared.blob.core.windows.net/media/2016/07/image3100.png)](https://msdnshared.blob.core.windows.net/media/2016/07/image3100.png)
3. Extract the web server into a local directory and then extract the apr packages into the srclib/ Run the following commands:
3. Extract the web server into a local directory and then extract the apr packages into the srclib/ directory. Run the following commands:
`cd <path to download directory>`
<br>`tar xvzf httpd-2.4.20.tar.gz`
<br>`tar xvzf apr-1.5.2.tar.gz`
<br> `tar xvzf apr-util-1.5.4.tar.gz`
<br>`mkdir httpd-2.4.20/srclib/apr-util`
<br>`cp -r apr-1.5.2/* httpd-2.4.20/srclib/apr`
<br>`cp -r apr-util-1.5.4/* httpd-2.4.20/srclib/apr-util`
<br>`cd httpd-2.4.20/`
`tar xvzf httpd-2.4.20.tar.gz`
`tar xvzf apr-1.5.2.tar.gz`
`tar xvzf apr-util-1.5.4.tar.gz`
`mkdir httpd-2.4.20/srclib/apr-util`
`cp -r apr-1.5.2/* httpd-2.4.20/srclib/apr`
`cp -r apr-util-1.5.4/* httpd-2.4.20/srclib/apr-util`
`cd httpd-2.4.20/`
4. Now we compile Apache. The compilation depends on whether the PHP drivers are thread safe. If you have downloaded the thread safe drivers (with names ending in _ts.so), run the following command:
`./configure --enable-so --with-mpm=worker`
If you have downloaded the non-thread safe drivers (with names ending in _nts.so), run:
`./configure --enable-so --with-mpm=prefork`
If you get a message saying that PCRE is not found, it can be installed with your package manager.
Run `sudo apt-get install libpcre3-dev on Ubuntu`, or `sudo yum install pcre-devel on CentOS`.
If you get a message saying that PCRE is not found, it can be installed with your package manager. Run `sudo apt-get install libpcre3-dev on Ubuntu`, or `sudo yum install pcre-devel on CentOS`.
5. Run `make` and `sudo make install` to complete the installation.
###To install Apache from your package manager, follow these steps:
1. If using Red Hat or CentOS, run the following command:
`sudo yum install httpd httpd-devel`
If using Ubuntu, run the following command:
`sudo apt-get install apache2 apache2-dev`
Note that your package manager's version of apache is likely not thread safe. To verify that Apache is installed and working properly, point your web browser to localhost/. If you installed from source, you will see a message saying 'It works!' If you installed from package, you may see a different landing page here is the landing page on Ubuntu:
Note that your package manager's version of Apache is likely not thread safe. To verify that Apache is installed and working properly, point your web browser to localhost/. If you installed from source, you will see a message saying 'It works!`. If you installed from package, you may see a different landing page here is the landing page on Ubuntu:
[![pic4](https://msdnshared.blob.core.windows.net/media/2016/07/image463.png)](https://msdnshared.blob.core.windows.net/media/2016/07/image463.png)
###Install PHP
Now you are ready to install PHP. You can install by source or, if the packaged version is PHP 7, with your package manager. However, we recommend you install from source. To install PHP from source, follow these instructions:
1. Download the latest stable PHP 7 source from [http://php.net/downloads.php](http://php.net/downloads.php). In what follows, we will assume the downloaded source file is php-7.0.8.tar.gz.
1. Download the latest stable PHP 7 source from [http://php.net/downloads.php](http://php.net/downloads.php). In what follows, we will assume the downloaded source file is `php-7.0.8.tar.gz`.
2. Run the following commands:
<br>`cd <path to download directory>`
<br>`tar xvzf php-7.0.8.tar.gz`
<br>`cd php-7.0.8/`
<br>`./buildconf --force`
`cd <path to download directory>`
`tar xvzf php-7.0.8.tar.gz`
`cd php-7.0.8/`
`./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/local/include/sql.h`, add `--with-unixODBC=/usr/local` 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. `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.
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`.
[![pic5](https://msdnshared.blob.core.windows.net/media/2016/07/image510.png)](https://msdnshared.blob.core.windows.net/media/2016/07/image510.png)
If your ./configure command exits with an error saying it cannot find xml2-config, you need to install libxml2-dev using your package manager before continuing. Run the following command: sudo yum install libxml2-devel on Red Hat or CentOS, or sudo apt-get install libxml2-dev on Ubuntu.
If your `./configure` command exits with an error saying it cannot find `xml2-config`, you need to install `libxml2-dev` using your package manager before continuing. Run the following command: `sudo yum install libxml2-devel` on Red Hat or CentOS, or `sudo apt-get install libxml2-dev` on Ubuntu.
4. Run `make` and then copy the downloaded PHP drivers into the modules/ directory.
5. Run `sudo make install` to install the binaries into the default php extensions directory.
6. Edit your Apache config file so that Apache can load PHP files. If you installed Apache from source, locate your httpd.conf file (using, for example, sudo find / -name httpd.conf) and add the following lines to it:
6. Edit your Apache config file so that Apache can load PHP files. If you installed Apache from source, locate your `httpd.conf` file (using, for example, `sudo find / -name httpd.conf`) and add the following lines to it:
`LoadModule php7_module modules/libphp7.so`
<br>`<FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> `
`LoadModule php7_module modules/libphp7.so`
`<FilesMatch \.php$>`
` SetHandler application/x-httpd-php`
`</FilesMatch>`
You can alter these lines to allow different file types to be parsed as PHP files. See [http://php.net/manual/en/install.unix.apache2.php](http://php.net/manual/en/install.unix.apache2.php) for more information.
You can alter these lines to allow different file types to be parsed as PHP files. See [http://php.net/manual/en/install.unix.apache2.php](http://php.net/manual/en/install.unix.apache2.php) for more information.
If you installed Apache via the package manager, the Apache config file(s) may have a different structure. In Ubuntu, you can find apache2.conf in /etc/apache2\. Add the above lines to this file.
If you installed Apache via the package manager, the Apache config file(s) may have a different structure. In Ubuntu, you can find `apache2.conf` in `/etc/apache2`. Add the above lines to this file.
###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. Follow these steps to install from the package manager on Ubuntu:
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.
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: .
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.
####Follow these steps to install from the package manager on Red Hat/CentOS:
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.
Now edit your php.ini file to load the PHP drivers when PHP starts.
###Compiling and installing Microsoft PHP drivers for SQLServer from source:
1. To find the location of your php.ini file, run php --ini to find the directory PHP searches for php.ini. You will see output similar to the following:
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/.
2. Unpack the PHP source and the SQL Server extension source, and copy the extension source to the PHP extension directory:
`cd <path to download directory>`
`tar xvzf php-7.0.8.tar.gz`
`cp r sqlsrv/ php-7.0.8/ext/`
`cp r pdo_sqlsrv/ php-7.0.8/ext/`
`cd php-7.0.8/`
`./buildconf --force`
3. Run `./configure` with the same options as described in step 3 above, in addition to the following:
a. `CXXFLAGS=-std=c++11` to ensure your compiler uses the C++11 standard.
b. `--enable-sqlsrv=shared`
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`.
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.
4. Run `make`. The compiled drivers will be located in the `modules/` directory, and are named `sqlsrv.so` and `pdo_sqlsrv.so`.
5. Run `sudo make install` to install the binaries into the default php extensions directory.
6. Edit your apache configuration file as described in step 6 above.
Now edit your `php.ini` file to load the PHP drivers when PHP starts.
1. To find the location of your `php.ini` file, run `php --ini` to find the directory PHP searches for `php.ini`. You will see output similar to the following:
[![pic6](https://msdnshared.blob.core.windows.net/media/2016/07/image611.png)](https://msdnshared.blob.core.windows.net/media/2016/07/image611.png)
If you installed PHP from package, the output will be slightly different and will likely list more .ini files, but you need only edit the php.ini file listed under Loaded Configuration File.
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`. 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.
4. Test your apache and PHP installation with a script that calls phpinfo(). Copy the following to a file called phpinfo.php:
`<?php phpinfo(); ?>` and copy that file to your web directory. This is likely to be either /var/www/html, or the htdocs/ directory in the Apache directory. In a web browser, go to localhost/phpinfo.php. You should see a page with information about your PHP installation, and information on enabled extensions, including sqlsrv and pdo_sqlsrv.
`<?php phpinfo(); ?>` and copy that file to your web directory. This is likely to be either `/var/www/html`, or the `htdocs/` directory in the Apache directory. In a web browser, go to localhost/phpinfo.php. You should see a page with information about your PHP installation, and information on enabled extensions, including sqlsrv and pdo_sqlsrv.
[![pic7](https://msdnshared.blob.core.windows.net/media/2016/07/image711.png)](https://msdnshared.blob.core.windows.net/media/2016/07/image711.png)
@ -157,10 +183,13 @@ Now edit your php.ini file to load the PHP drivers when PHP starts.
[![pic9](https://msdnshared.blob.core.windows.net/media/2016/07/image915.png)](https://msdnshared.blob.core.windows.net/media/2016/07/image915.png)
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.
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:
<br>Microsoft PHP GitHub repository https://github.com/Azure/msphpsql
<br>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) <br>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) <br>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) <br>Apache source: [http://httpd.apache.org/download.cgi#apache24](http://httpd.apache.org/download.cgi)
<br>Apache Portable Runtime (APR): [http://apr.apache.org/download.cgi](http://apr.apache.org/download.cgi)
<br>PHP source download page: [http://php.net/downloads.php](http://php.net/downloads.php)
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)

View file

@ -3,15 +3,17 @@ rm -rf /tmp/msodbcubuntu
mkdir /tmp/msodbcubuntu
sudo wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.1.tar.gz -P /tmp/msodbcubuntu/
cd /tmp/msodbcubuntu
sudo tar -xzf /tmp/msodbcubuntu/unixODBC-2.3.1.tar.gz
cd /tmp/msodbcubuntu/unixODBC-2.3.1/
sudo tar -xzf /tmp/msodbcubuntu/unixODBC-2.3.1.tar.gz
cd /tmp/msodbcubuntu/unixODBC-2.3.1/
sudo -i export CPPFLAGS="-DSIZEOF_LONG_INT=8"
sudo apt-get -y install g++-5
echo "Configuring the unixODBC 2.3.1 Driver Manager"
./configure --disable-gui --disable-drivers --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE 1> odbc_con.log 2> moake_err.log
./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc --disable-gui --disable-drivers --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE 1> odbc_con.log 2> make_err.log
echo "Building and Installing the unixODBC 2.3.1 Driver Manager"
sudo make 1> make_std.log 2> moake_err.log
sudo make 1> make_std.log 2> make_err.log
sudo make install 1> makeinstall_std.log 2> makeinstall_err.log
echo "Downloading the Microsoft ODBC Driver 13 for SQL Server- Ubuntu"
wget https://download.microsoft.com/download/2/E/5/2E58F097-805C-4AB8-9FC6-71288AB4409D/msodbcsql-13.0.0.0.tar.gz -P /tmp/msodbcubuntu
cd /tmp/msodbcubuntu/
@ -21,6 +23,7 @@ ldd /tmp/msodbcubuntu/msodbcsql-13.0.0.0/lib64/libmsodbcsql-13.0.so.0.0
echo "Installing Dependencies"
sudo apt-get -y install libssl1.0.0
sudo apt-get -y install libgss3
sudo echo "/usr/lib64" >> /etc/ld.so.conf
sudo ldconfig
echo "Installing the Microsoft ODBC Driver 13 for SQL Server- Ubuntu"
sudo bash ./install.sh install --force --accept-license

217
README .md Normal file
View file

@ -0,0 +1,217 @@
# Microsoft Drivers for PHP for SQL Server
**Welcome to the Microsoft Drivers for PHP for SQL Server PHP 7 Linux (Early Technical Preview)**
The Microsoft Drivers for PHP for SQL Server are PHP extensions that allow for the reading and writing of SQL Server data from within PHP scripts. The SQLSRV extension provides a procedural interface while the PDO_SQLSRV extension implements PDO for accessing data in all editions of SQL Server 2005 and later (including Azure SQL DB). These drivers rely on the Microsoft ODBC Driver for SQL Server to handle the low-level communication with SQL Server.
This preview contains the SQLSRV and PDO_SQLSRV drivers for PHP 7 (64-bit) with limitations (see Limitations below for details). Upcoming release(s) will contain more functionality, bug fixes, and more.
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:
- Fixed data corruption in binding integer parameters.
- Fixed invalid sql_display_size error.
- Fixed issue with invalid statement options.
- 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:
- The PDO_SQLSRV driver no longer requires PDO to be built as a shared extension.
- Fixed an issue with format specifiers in error messages.
- Fixed a segmentation fault when using buffered cursors.
- 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:
- Improved handling varchar(MAX).
- Improved handling basic stream operations.
June 20, 2016 (4.0.0): The early technical preview (ETP) for SQLSRV and PDO_SQLSRV drivers for Linux with basic functionalities is now available. The SQLSRV driver has been built and tested on Ubuntu 15.04, Ubuntu 16.04, and RedHat 7.2, and PDO_SQLSRV driver has been built and tested on Ubuntu 15.04, Ubuntu 16.04.
####Prerequisites
- A Web server such as Apache is required. Your Web server must be configured to run PHP. See below for information on installing Apache to work with the drivers.
- [Microsoft ODBC Driver 13 for Linux][odbcLinux]
- 64-bit [UnixODBC 2.3.1 driver manager][LinuxDM], built for 64-bit SQLLEN/SQLULEN.
- If building PHP from source, you need libraries required to [build PHP][PHPMan].
## 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`.
4. Run `make` and `sudo make install`.
Install [Microsoft ODBC Driver 13 on Linux][odbcLinux] and Driver manager using the instructions on MSDN. Run `sqlcmd -S <myserver> -d <mydatabase> -U <myusername> -P <mypassword> -I` to make sure ODBC driver and driver manager have been installed successfully.
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.
1. Use your package manager to install php and php-odbc.
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.
- 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.
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`.
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`.
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.
3. Run `make` and then put the precompiled binaries into the < php_source_directory >/modules/ directory.
4. Run `make install` to install the binaries into the default php extensions directory.
- Method 3: Compile the drivers from source along with PHP:
Download the PHP 7 source and unzip it to a local directory. Then follow the steps below:
1. Switch to the PHP directory and unzip the Linux driver sources to the `ext/` directory. There are two directories, `sqlsrv/` and `pdo_sqlsrv/`. Run `./buildconf --force`. You may need to install autoconf with your package-manager prior to this step.
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.
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`.
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.
####Enable the drivers
1. Make sure that the driver is in your PHP extensions directory.
2. Enable it within your PHP installation's php.ini: In your local PHP directory, copy `php.ini-development` to `php.ini`. If using the SQLSRV driver, add `extension=php_sqlsrv_7_ts.so` or `extension=php_sqlsrv_7_nts.so` to `php.ini`. If using the PDO_SQLSRV driver, add `extension=php_pdo_sqlsrv_7_ts.so` or `extension=php_pdo_sqlsrv_7_nts.so`. Modify these filenames as appropriate if you compiled the drivers from source. If necessary, specify the extension directory using `extension_dir`, for example: `extension_dir = /usr/local/bin`.
3. If using Apache web server, follow the [instructions here][httpdconf] for editing your Apache configuration file.
4. Restart the web server.
## Sample Code
For samples, please see the sample folder. For setup instructions, see [here] [phpazure]
## Limitations
- This preview contains the PHP 7 port of the SQLSRV and PDO_SQLSRV drivers, and does not provide backwards compatibility with PHP 5.
- 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.
- Integrated authentication is not supported.
- Buffered cursors are not supported.
- Fetch object and fetch array have issues.
- lastInsertId().
- Query from large column name.
- ODBC 3.52 is supported but not 3.8.
## Guidelines for Reporting Issues
We appreciate you taking the time to test the driver, provide feedback and report any issues. It would be extremely helpful if you:
- Report each issue as a new issue (but check first if it's already been reported)
- Try to be detailed in your report. Useful information for good bug reports include:
* What you are seeing and what the expected behaviour is
* Can you connect to SQL Server via `sqlcmd`?
* Which driver: SQLSRV or PDO_SQLSRV?
* Environment details: e.g. PHP version, thread safe (TS) or non-thread safe (NTS)?
* Table schema (for some issues the data types make a big difference!)
* Any other relevant information you want to share
- Try to include a PHP script demonstrating the isolated problem.
Thank you!
## FAQs
**Q:** Can we get dates for any of the Future Plans listed above?
**A:** At this time, Microsoft is not able to announce dates. We are working extremely hard to release future versions of the driver. We will share future plans once they solidify over the next few weeks.
**Q:** What's next?
**A:** On July 20, 2016 we released the early technical preview for our PHP Driver. We will continue releasing frequent technical previews until we reach production quality.
**Q:** Is Microsoft taking pull requests for this project?
**A:** We will not be seeking to take pull requests until GA, Build Verification, and Fundamental tests are released. At this point Microsoft will also begin actively developing using this GitHub project as the prime repository.
## License
The Microsoft Drivers for PHP for SQL Server are licensed under the MIT license. See the LICENSE file for more details.
## Code of conduct
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
## Resources
**Documentation**: [MSDN Online Documentation][phpdoc]. Please note that this documentation is not yet updated for PHP 7.
**Team Blog**: Browse our blog for comments and announcements from the team in the [team blog][blog].
**Known Issues**: Please visit the [project on Github][project] to view outstanding [issues][issues] and report new ones.
[blog]: http://blogs.msdn.com/b/sqlphp/
[project]: https://github.com/Azure/msphpsql
[issues]: https://github.com/Azure/msphpsql/issues
[phpweb]: http://php.net
[phpbuild]: https://wiki.php.net/internals/windows/stepbystepbuild
[phpdoc]: http://msdn.microsoft.com/library/dd903047%28SQL.11%29.aspx
[odbc11]: https://www.microsoft.com/download/details.aspx?id=36434
[odbc13]: https://www.microsoft.com/download/details.aspx?id=50420
[odbcLinux]: https://msdn.microsoft.com/library/hh568454(v=sql.110).aspx
[phpazure]: https://azure.microsoft.com/documentation/articles/sql-database-develop-php-simple-windows/
[PHPMan]: http://php.net/manual/install.unix.php
[LinuxDM]: https://msdn.microsoft.com/library/hh568449(v=sql.110).aspx
[httpd_source]: http://httpd.apache.org/
[apr_source]: http://apr.apache.org/
[httpdconf]: http://php.net/manual/en/install.unix.apache2.php

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,4 @@
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 +1,4 @@
5282b0239d55a373ae424da2b6c1df9fe1728fc4787b3f96be500391c3a59615 php_sqlsrv_7_nts.so
e91639ab62b126f10da41ea40403d1613735360dc92f2f866655569722c2e0bb php_pdo_sqlsrv_7_nts.so
769b2e8c35e75ccd87f507db486ab38e48cdad4225fae22d6bd03212eba8ce91 php_sqlsrv_7_ts.so
c95b2ffb5d253f93e197fa7eda9f0ee65d05963b50618921ba6063901a6bb40d php_pdo_sqlsrv_7_ts.so
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 +1,4 @@
e3d40793c7091a3858f1c8259282c4fe937793efc2772f954248302eec0e5968 php_pdo_sqlsrv_7_nts.so
84a8b04fb23816c43a53f38a6315394f90088efa7319750dc7530d0557688fcf php_pdo_sqlsrv_7_ts.so
4ff57316ea7291d388d2323d2580c998c052f40188bcbd06d84187c7103d960b php_sqlsrv_7_nts.so
bdb368eac4314d437009c698631eb0b7854792a4c0ae071149b0e7c147d6e905 php_sqlsrv_7_ts.so
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

@ -1352,7 +1352,6 @@ void core_sqlsrv_set_send_at_exec( sqlsrv_stmt* stmt, zval* value_z TSRMLS_DC );
bool core_sqlsrv_send_stream_packet( sqlsrv_stmt* stmt TSRMLS_DC );
void core_sqlsrv_set_buffered_query_limit( sqlsrv_stmt* stmt, zval* value_z TSRMLS_DC );
void core_sqlsrv_set_buffered_query_limit( sqlsrv_stmt* stmt, SQLLEN limit TSRMLS_DC );
void core_finalize_output_parameters(sqlsrv_stmt* stmt TSRMLS_DC);
//*********************************************************************************************************************************

View file

@ -1330,10 +1330,6 @@ bool core_sqlsrv_send_stream_packet( sqlsrv_stmt* stmt TSRMLS_DC )
return true;
}
void core_finalize_output_parameters(sqlsrv_stmt* stmt TSRMLS_DC) {
finalize_output_parameters(stmt TSRMLS_CC);
}
void stmt_option_functor::operator()( sqlsrv_stmt* /*stmt*/, stmt_option const* /*opt*/, zval* /*value_z*/ TSRMLS_DC )
{
TSRMLS_C;
@ -1811,7 +1807,15 @@ SQLSMALLINT default_c_type( sqlsrv_stmt* stmt, SQLULEN paramno, zval const* para
case IS_TRUE:
case IS_FALSE:
case IS_LONG:
sql_c_type = SQL_C_LONG;
//ODBC 64-bit long and integer type are 4 byte values.
if ( ( Z_LVAL_P( param_z ) < INT_MIN ) || ( Z_LVAL_P( param_z ) > INT_MAX ) )
{
sql_c_type = SQL_C_SBIGINT;
}
else
{
sql_c_type = SQL_C_SLONG;
}
break;
case IS_DOUBLE:
sql_c_type = SQL_C_DOUBLE;
@ -1874,7 +1878,16 @@ void default_sql_type( sqlsrv_stmt* stmt, SQLULEN paramno, zval* param_z, SQLSRV
case IS_TRUE:
case IS_FALSE:
case IS_LONG:
sql_type = SQL_INTEGER;
//ODBC 64-bit long and integer type are 4 byte values.
if ( ( Z_LVAL_P( param_z ) < INT_MIN ) || ( Z_LVAL_P( param_z ) > INT_MAX ) )
{
sql_type = SQL_BIGINT;
}
else
{
sql_type = SQL_INTEGER;
}
break;
case IS_DOUBLE:
sql_type = SQL_FLOAT;
@ -1941,12 +1954,13 @@ void default_sql_size_and_scale( sqlsrv_stmt* stmt, unsigned int paramno, zval*
break;
case IS_STRING:
{
SQLULEN byte_len = Z_STRLEN_P( param_z ) * ((encoding == SQLSRV_ENCODING_UTF8) ? sizeof( SQLWCHAR ) : sizeof( char ));
size_t char_size = Z_STRLEN_P( param_z ) * ((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;
}
else {
column_size = Z_STRLEN_P( param_z );
column_size = SQL_SERVER_MAX_FIELD_SIZE / char_size;
}
break;
}
@ -2129,8 +2143,8 @@ void get_field_as_string( sqlsrv_stmt* stmt, SQLUSMALLINT field_index, sqlsrv_ph
calc_string_size( stmt, field_index, sql_field_type, sql_display_size TSRMLS_CC );
// if this is a large type, then read the first few bytes to get the actual length from SQLGetData
if( sql_display_size == 0 || sql_display_size == LONG_MAX ||
sql_display_size == LONG_MAX >> 1 || sql_display_size == ULONG_MAX - 1 ) {
if( sql_display_size == 0 || sql_display_size == INT_MAX ||
sql_display_size == INT_MAX >> 1 || sql_display_size == UINT_MAX - 1 ) {
field_len_temp = INITIAL_FIELD_STRING_LEN;

View file

@ -479,8 +479,8 @@ int pdo_sqlsrv_db_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_DC)
zend_string_release( Z_STR( server_z ));
}
dbh->error_mode = prev_err_mode; // reset the error mode
g_henv_cp->invalidate();
return 0;
g_henv_cp->last_error().reset(); // reset the last error; callee will check if last_error exist before freeing it and setting it to NULL
return 0;
}
catch( ... ) {

View file

@ -225,7 +225,7 @@ zval convert_to_zval( SQLSRV_PHPTYPE sqlsrv_php_type, void** in_val, SQLLEN fiel
else {
if( sqlsrv_php_type == SQLSRV_PHPTYPE_INT ) {
ZVAL_LONG( &out_zval, **( reinterpret_cast<long**>( in_val )));
ZVAL_LONG( &out_zval, **( reinterpret_cast<int**>( in_val )));
}
else {
ZVAL_DOUBLE( &out_zval, **( reinterpret_cast<double**>( in_val )));
@ -769,11 +769,6 @@ int pdo_sqlsrv_stmt_get_col_data(pdo_stmt_t *stmt, int colno,
SQLSRV_PHPTYPE sqlsrv_phptype_out = SQLSRV_PHPTYPE_INVALID;
core_sqlsrv_get_field( driver_stmt, colno, sqlsrv_php_type, false, *(reinterpret_cast<void**>(ptr)),
reinterpret_cast<SQLLEN*>( len ), true, &sqlsrv_phptype_out TSRMLS_CC );
// if the current column is the last fetch column, finalize output params
if ( stmt->column_count == colno + 1 ) {
core_finalize_output_parameters( driver_stmt TSRMLS_CC );
}
zval* zval_ptr = reinterpret_cast<zval*>( sqlsrv_malloc( sizeof( zval )));
*zval_ptr = convert_to_zval( sqlsrv_phptype_out, reinterpret_cast<void**>( ptr ), *len );

View file

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

View file

@ -1198,7 +1198,7 @@ void add_stmt_option_key( sqlsrv_context& ctx, zend_string* key, size_t key_len,
{
int option_key = ::get_stmt_option_key( key, key_len TSRMLS_CC );
CHECK_CUSTOM_ERROR((option_key == SQLSRV_STMT_OPTION_INVALID ), ctx, SQLSRV_ERROR_INVALID_OPTION_KEY, key ) {
CHECK_CUSTOM_ERROR((option_key == SQLSRV_STMT_OPTION_INVALID ), ctx, SQLSRV_ERROR_INVALID_OPTION_KEY, ZSTR_VAL( key ) ) {
throw ss::SSException();
}
@ -1240,17 +1240,14 @@ void validate_stmt_options( sqlsrv_context& ctx, zval* stmt_options, _Inout_ Has
zval* conn_opt = NULL;
int result = 0;
key_len = ZSTR_LEN( key ) + 1;
type = key ? HASH_KEY_IS_STRING : HASH_KEY_IS_LONG;
/*
if( type != HASH_KEY_IS_STRING ) {
std::ostringstream itoa;
itoa << int_key;
CHECK_CUSTOM_ERROR( true, ctx, SQLSRV_ERROR_INVALID_OPTION_KEY, itoa.str() ) {
if (type != HASH_KEY_IS_STRING) {
CHECK_CUSTOM_ERROR(true, ctx, SQLSRV_ERROR_INVALID_OPTION_KEY, std::to_string( int_key ).c_str() ) {
throw core::CoreException();
}
}
*/
key_len = ZSTR_LEN(key) + 1;
add_stmt_option_key( ctx, key, key_len, ss_stmt_options_ht, data TSRMLS_CC );
} ZEND_HASH_FOREACH_END();
}

View file

@ -1352,7 +1352,6 @@ void core_sqlsrv_set_send_at_exec( sqlsrv_stmt* stmt, zval* value_z TSRMLS_DC );
bool core_sqlsrv_send_stream_packet( sqlsrv_stmt* stmt TSRMLS_DC );
void core_sqlsrv_set_buffered_query_limit( sqlsrv_stmt* stmt, zval* value_z TSRMLS_DC );
void core_sqlsrv_set_buffered_query_limit( sqlsrv_stmt* stmt, SQLLEN limit TSRMLS_DC );
void core_finalize_output_parameters(sqlsrv_stmt* stmt TSRMLS_DC);
//*********************************************************************************************************************************

View file

@ -1330,10 +1330,6 @@ bool core_sqlsrv_send_stream_packet( sqlsrv_stmt* stmt TSRMLS_DC )
return true;
}
void core_finalize_output_parameters(sqlsrv_stmt* stmt TSRMLS_DC) {
finalize_output_parameters(stmt TSRMLS_CC);
}
void stmt_option_functor::operator()( sqlsrv_stmt* /*stmt*/, stmt_option const* /*opt*/, zval* /*value_z*/ TSRMLS_DC )
{
TSRMLS_C;
@ -1811,7 +1807,15 @@ SQLSMALLINT default_c_type( sqlsrv_stmt* stmt, SQLULEN paramno, zval const* para
case IS_TRUE:
case IS_FALSE:
case IS_LONG:
sql_c_type = SQL_C_LONG;
//ODBC 64-bit long and integer type are 4 byte values.
if ( ( Z_LVAL_P( param_z ) < INT_MIN ) || ( Z_LVAL_P( param_z ) > INT_MAX ) )
{
sql_c_type = SQL_C_SBIGINT;
}
else
{
sql_c_type = SQL_C_SLONG;
}
break;
case IS_DOUBLE:
sql_c_type = SQL_C_DOUBLE;
@ -1874,7 +1878,16 @@ void default_sql_type( sqlsrv_stmt* stmt, SQLULEN paramno, zval* param_z, SQLSRV
case IS_TRUE:
case IS_FALSE:
case IS_LONG:
sql_type = SQL_INTEGER;
//ODBC 64-bit long and integer type are 4 byte values.
if ( ( Z_LVAL_P( param_z ) < INT_MIN ) || ( Z_LVAL_P( param_z ) > INT_MAX ) )
{
sql_type = SQL_BIGINT;
}
else
{
sql_type = SQL_INTEGER;
}
break;
case IS_DOUBLE:
sql_type = SQL_FLOAT;
@ -1941,12 +1954,13 @@ void default_sql_size_and_scale( sqlsrv_stmt* stmt, unsigned int paramno, zval*
break;
case IS_STRING:
{
SQLULEN byte_len = Z_STRLEN_P( param_z ) * ((encoding == SQLSRV_ENCODING_UTF8) ? sizeof( SQLWCHAR ) : sizeof( char ));
size_t char_size = Z_STRLEN_P( param_z ) * ((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;
}
else {
column_size = Z_STRLEN_P( param_z );
column_size = SQL_SERVER_MAX_FIELD_SIZE / char_size;
}
break;
}
@ -2129,8 +2143,8 @@ void get_field_as_string( sqlsrv_stmt* stmt, SQLUSMALLINT field_index, sqlsrv_ph
calc_string_size( stmt, field_index, sql_field_type, sql_display_size TSRMLS_CC );
// if this is a large type, then read the first few bytes to get the actual length from SQLGetData
if( sql_display_size == 0 || sql_display_size == LONG_MAX ||
sql_display_size == LONG_MAX >> 1 || sql_display_size == ULONG_MAX - 1 ) {
if( sql_display_size == 0 || sql_display_size == INT_MAX ||
sql_display_size == INT_MAX >> 1 || sql_display_size == UINT_MAX - 1 ) {
field_len_temp = INITIAL_FIELD_STRING_LEN;

View file

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