-
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
Unable to handle SQL_VARIANT types #51
Comments
This is still an issue today running IIS 10 / PHP 7.1.1 / using SQLSRV RC 4.1.3. Is there a fix in the works? |
@stevebauman PHP drivers rely on ODBC to handle SQL data types, and SQL_VARIANT is not supported in ODBC. We're looking into David's suggestion to see if SQL variants can be handled with string inferred type. |
@Hadis-Fard Awesome! Thanks for the reply :). |
@stevebauman @david-garcia-garcia we added support for sql variants in 4.2.0-preview, you can get the driver from our PECL repositiry or GitHub releases page. Note that sqlvariant for output parameters is not supported. |
The PDO driver is chocking on SQL_VARIANT types, but this can contain themselves simple types such as char, intenger, etc...
Steps to reproduce:
CREATE FUNCTION [dbo].[GREATEST](@OP1 sql_variant, @OP2 sql_variant) RETURNS sql_variant AS
BEGIN
DECLARE @Result sql_variant
SET @Result = CASE WHEN @OP1 >= @OP2 THEN @OP1 ELSE @OP2 END
RETURN @Result
END
GO
SELECT dbo.GREATEST(5, 6)
Without Buffered Queries:
SQLSTATE[IMSSP]: Invalid type.
With Buffered Queries:
Fatal error: Unknown type in sqlsrv_buffered_query::sqlsrv_buffered_query
I can manage to get it to work if I use PDO::PARAM_INT on the column before the fetch, but there is no way that I can infer this informatino from the PDO metadata (getColumnMeta) that is reporting:
sql_srv_type = sql_variant
native_type = string
Possible solutions.....
The text was updated successfully, but these errors were encountered: