From 6ba343aeff1af7fac3603f56c9d9b25320cb88b1 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sat, 5 Mar 2011 23:07:45 +0000 Subject: [PATCH] - Fixed bug #54167 (PDO_DBLIB returns null on SQLUNIQUE field) # initial patch by: mjh at hodginsmedia dot com (5.3) # trunk version by me --- ext/pdo_dblib/dblib_stmt.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ext/pdo_dblib/dblib_stmt.c b/ext/pdo_dblib/dblib_stmt.c index 0df0a1d098..c7c48f5916 100644 --- a/ext/pdo_dblib/dblib_stmt.c +++ b/ext/pdo_dblib/dblib_stmt.c @@ -25,6 +25,7 @@ #include "php.h" #include "php_ini.h" +#include "ext/standard/php_string.h" #include "ext/standard/info.h" #include "pdo/php_pdo.h" #include "pdo/php_pdo_driver.h" @@ -224,6 +225,24 @@ static int pdo_dblib_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, *ptr = tmp_ptr; break; } +#ifdef SQLUNIQUE + case SQLUNIQUE: { +#else + case 36: { /* FreeTDS hack, also used by ext/mssql */ +#endif + *len = 36+1; + tmp_ptr = emalloc(*len + 1); + + /* uniqueidentifier is a 16-byte binary number, convert to 32 char hex string */ +#ifdef SQLUNIQUE + *len = dbconvert(NULL, SQLUNIQUE, ptr, *len, SQLCHAR, tmp_ptr, *len); +#else + *len = dbconvert(NULL, 36, ptr, *len, SQLCHAR, tmp_ptr, *len); +#endif + php_strtoupper(tmp_ptr, *len); + *ptr = tmp_ptr; + break; + } default: if (dbwillconvert(coltype, SQLCHAR)) { tmp_len = 32 + (2 * (*len)); -- 2.50.1