]> granicus.if.org Git - php/commitdiff
- Fixed bug #54167 (PDO_DBLIB returns null on SQLUNIQUE field)
authorFelipe Pena <felipe@php.net>
Sat, 5 Mar 2011 23:07:45 +0000 (23:07 +0000)
committerFelipe Pena <felipe@php.net>
Sat, 5 Mar 2011 23:07:45 +0000 (23:07 +0000)
# initial patch by: mjh at hodginsmedia dot com (5.3)
# trunk version by me

ext/pdo_dblib/dblib_stmt.c

index 0df0a1d0984bbeb15ea1b2f021de04d141865d7e..c7c48f59163bb69d1d2f4679e8168a1b666f9b07 100644 (file)
@@ -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));