The unixODBC attribute DMStmtAttr
lets you set statement attributes in your ODBC data source. The process for setting standard ODBC statement attributes (those defined in the ODBC specification) is described in our ODBC on Linux and UNIX platforms.
Some ODBC drivers provide non-standard statement attributes that allow database-specific functionality to be requested or configured. In unixODBC 2.3.3 and later, you can also use DMStmtAttr
to set these custom statement attributes:
For example, the header file sqlncli.h
contains a number of SQL Server statement attributes. This header file is included in the SQL Server ODBC driver distribution. For example:
$ cd /usr/local/easysoft/sqlserver/include $ vi sqlncli.h
We wanted to request a SQL Server query notification from PHP. The relevant statement attributes for us were:
#define SQL_SOPT_SS_BASE 1225 . . . /* Query notification options */ #define SQL_SOPT_SS_QUERYNOTIFICATION_TIMEOUT (SQL_SOPT_SS_BASE+8) #define SQL_SOPT_SS_QUERYNOTIFICATION_MSGTEXT (SQL_SOPT_SS_BASE+9) #define SQL_SOPT_SS_QUERYNOTIFICATION_OPTIONS (SQL_SOPT_SS_BASE+10)
For example, we wanted to set all three query notification options. The integer values for these attributes were 1333
(1225
+8
), 1334
and 1335
.
DMStmtAttr
attribute to set the statement attribute values.
The format is:
DMStmtAttr=[xxxx]=\yyyy;[xxxx]={ssss}
where xxxx
is the integer attribute to set, yyyy
is a decimal numeric value and ssss
is a string value.
We used DMStmtAttr
to request a query notification subscription, set a timeout, and define a query notification message:
DMStmtAttr=[1233]=\3600;[1234]={Person.Contact has changed};[1235]={service=ContactChangeNotifications}
LD_LIBRARY_PATH=/usr/local/lib php subscribe.php