-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bit-parameter with PHP 7.0.5 x64 NTS and SQLSRV 4.0.3 x64 #87
Comments
@eskimoe good catch! We were able to repro this. Will work towards fixing it. |
Thanks! One other thing, didn't want to open a new ticket, but just say so if I should... Anyways, most of the SQL_*-constants I could replace with it's SQLSRV_SQLTYPE-counterpart, |
@eskimoe : SQLSRV_SQLTYPE_DECIMAL should exist. Can you give us an example of what you’re trying to do? Also, which version of the sqlsrv extension are you referring to as the old one? |
Here we go: $tsql = 'SELECT CAST(1.1 AS decimal(5,2))'; $stmt = sqlsrv_query($conn, $tsql); $fieldMetadata = sqlsrv_field_metadata($stmt); echo '<pre>'; var_dump($fieldMetadata); echo '===3 ? ' . ($fieldMetadata[0]['Type'] == 3 ? 'true' : 'false') . "\r\n"; echo '==SQL_DECIMAL ? ' . ($fieldMetadata[0]['Type'] == SQL_DECIMAL ? 'true' : 'false') . "\r\n"; echo '==SQLSRV_SQLTYPE_DECIMAL ? ' . ($fieldMetadata[0]['Type'] == SQLSRV_SQLTYPE_DECIMAL ? 'true' : 'false') . "\r\n"; echo '</pre>'; When executing this code on php 7.0.5 with sqlsrv 4.0.3, only the first condition matches (==3), |
Hi eskimoe, Seems like this behaviour is casued by the fact that PHP 7 does not ship with php-odbc by default. Here is a stack overflow link that might help our casue here - http://stackoverflow.com/questions/34200997/php-7-0-odbc-driver-for-windows Let us know if you are still running into issues and we will work through it. Cheers, |
okay, the bit-binding seems to work, very nice! regarding the sqltype constants, you are right of course, all the constants beginning with "SQL_" come from the odbc-extension! First, SQLSRV_SQLTYPE_BINARY doesn't exist in either sqlsrv-extension. Additionally, all the sqltypes that require a parameter in the sqlserver, like: And finally, a lot of the sqltypes have weird and incorrect values in both versions, like smalldatetime = 8285 in sqsrv 3.2, and 8781060644957 in sqlsrv 7.0.6, but your sqlsrv_field_metadata returns ["Type"]=>int(93) for it! |
Oh, and I used get_defined_constants(true) for that... |
Hi @eskimoe , we believe this issue is fixed in our latest RTW release - https://github.com/Azure/msphpsql/releases/tag/v4.0-RTW. Can you help us validate? |
It seems the 4.0.3 version of the PHP7-branch has problems with bit-parameters...
I am using PHP 7.0.5 x64 NTS, plus the 4.0.3 SQLSRV x64.
When using the following code:
Output with PHP 5 and the old sqlsrv:
Output with PHP7 and the new sqlsrv:
As you can see, even the old sqlsrv interprets the parameters as ints, and returns int-values, too,
but at least it reads the parameters correctly...
With PHP7, it only does weird things! when casting to bit with t-sql, it uses '1' for true AND false,
when casting to int, or using the bits directly, it uses '2' for both true and false??
Thanks!
The text was updated successfully, but these errors were encountered: