Skip to content

Commit

Permalink
Add support for ODBCRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
wez committed Jan 13, 2005
1 parent ef0de01 commit f17311c
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ext/odbc/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,33 @@ AC_ARG_WITH(ibm-db2,
])
fi

if test -z "$ODBC_TYPE"; then
AC_MSG_CHECKING(for ODBCRouter.com support)
AC_ARG_WITH(ODBCRouter,
[ --with-ODBCRouter[=DIR] Include ODBCRouter.com support. DIR is ODBCRouter base
install directory, defaults to /usr.],
[
PHP_WITH_SHARED
if test "$withval" = "yes"; then
withval=/usr
fi
if test "$withval" != "no"; then
ODBC_INCDIR=$withval/include
ODBC_LIBDIR=$withval/lib
ODBC_LFLAGS=-L$ODBC_LIBDIR
ODBC_INCLUDE=-I$ODBC_INCDIR
ODBC_LIBS=-lodbcsdk
ODBC_TYPE=ODBCRouter
AC_DEFINE(HAVE_ODBC_ROUTER,1,[ ])
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
],[
AC_MSG_RESULT(no)
])
fi

if test -z "$ODBC_TYPE"; then
AC_MSG_CHECKING(for Empress support)
AC_ARG_WITH(empress,
Expand Down
42 changes: 42 additions & 0 deletions ext/odbc/php_odbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2073,6 +2073,47 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
SQLSetConnectOption((*conn)->hdbc, SQL_TRANSLATE_OPTION,
SQL_SOLID_XLATOPT_NOCNV);
#endif
#ifdef HAVE_ODBC_ROUTER
{
#define CONNSTRSIZE 2048
char *lpszConnStr = emalloc(CONNSTRSIZE);
if (lpszConnStr && db) {
short cbszConnStr;
if (strstr(db, ";")) {
/* the caller has apparently passed a connection-string */
if (strstr(db, "uid") || strstr(db, "UID")) {
uid = NULL;
}
if (strstr(db, "pwd") || strstr(db, "PWD")) {
pwd = NULL;
}
strncpy( lpszConnStr, db, CONNSTRSIZE);
}
else {
strcpy(lpszConnStr, "DSN=");
strcat(lpszConnStr, db);
}
if (uid) {
if (uid[0]) {
strcat(lpszConnStr, ";UID=");
strcat(lpszConnStr, uid);
strcat(lpszConnStr, ";");
}
if (pwd) {
if (pwd[0]) {
strcat(lpszConnStr, "PWD=");
strcat(lpszConnStr, pwd);
strcat(lpszConnStr, ";");
}
}
}
rc = SQLDriverConnect((*conn)->hdbc, NULL, lpszConnStr, SQL_NTS,
lpszConnStr, CONNSTRSIZE, &cbszConnStr,
SQL_DRIVER_NOPROMPT);
efree(lpszConnStr);
}
}
#else
#ifdef HAVE_OPENLINK
{
char dsnbuf[1024];
Expand Down Expand Up @@ -2130,6 +2171,7 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
#else
rc = SQLConnect((*conn)->hdbc, db, SQL_NTS, uid, SQL_NTS, pwd, SQL_NTS);
#endif
#endif
#endif
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
odbc_sql_error(*conn, SQL_NULL_HSTMT, "SQLConnect");
Expand Down
14 changes: 14 additions & 0 deletions ext/odbc/php_odbc_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ PHP_FUNCTION(solid_fetch_prev);
#include <sqlext.h>
#define HAVE_SQL_EXTENDED_FETCH 1

#elif defined(HAVE_ODBC_ROUTER) /* ODBCRouter.com */

#ifdef CHAR
#undef CHAR
#endif

#ifdef SQLCHAR
#undef SQLCHAR
#endif

#define ODBC_TYPE "ODBCRouter"
#include <odbcsdk.h>
#undef HAVE_SQL_EXTENDED_FETCH

#elif defined(HAVE_OPENLINK) /* OpenLink ODBC drivers */

#define ODBC_TYPE "Openlink"
Expand Down

0 comments on commit f17311c

Please sign in to comment.