Without any parameters it will works fine, but when parameters are there, gives the following error -
SQLSTATE[42000]: Syntax error or access violation: 8018 [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid parameter 4 (''): Data type 0x23 is a deprecated large object, or LOB, but is marked as output parameter. Deprecated types are not supported as output parameters. Use current large object t (SQLExecute[8018] at /builddir/build/BUILD/php-5.3.3/ext/pdo_odbc/odbc_stmt.c:254)
This runs on Centos 6 , ODBC Driver 11 for SQL Server® - RedHat Linux , unixODBC-2.3.0 , MSSQL Server 2008 R2
Connection string :
$con = new PDO("odbc:dsnName", 'sa','saa');
$con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$con->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
Sample stored procedure used :
$stmt = $con->prepare( "SET NOCOUNT ON DECLARE @return_value int
EXEC @return_value = [sp_insert_into_t_contact_test]
@paravalue = ?
SELECT 'returnV' = @return_value");
$stmt->bindParam(1, $v1 = 5, PDO::PARAM_STR, 100);
$stmt->execute();
$return =$stmt->fetch();
echo $return['returnV'];
Simple stored procedure to return "123"
[dbo].[sp_insert_into_t_contact_test]
@paravalue varchar(100)
AS
return 123
Additional information -
odbc.ini file -
[dsnName]
Driver=SQL Server Native Client 11.0
Description=My Sample ODBC Database Connection
Trace=Yes
Server=192.168.2.60
Port=1433
Database=NSCDB_3
odbcinst.ini
[SQL Server Native Client 11.0]
Description=Microsoft ODBC Driver 11 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0
Threading=1
UsageCount=1